Add database initialization implementation.
This commit is contained in:
parent
f3f3512068
commit
724fbac33a
|
@ -21,7 +21,7 @@ pub trait DBOps {
|
|||
// type TxRef; // Backend-specific transaction handle
|
||||
// type NoteRef; // Backend-specific note identifier`
|
||||
|
||||
// fn init_db() -> Result<(), Self::Error>;
|
||||
fn init_db(&self) -> Result<(), Self::Error>;
|
||||
//
|
||||
// fn init_accounts(extfvks: &[ExtendedFullViewingKey]) -> Result<(), Self::Error>;
|
||||
//
|
||||
|
@ -42,8 +42,6 @@ pub trait DBOps {
|
|||
block_height: BlockHeight,
|
||||
) -> Result<(), Self::Error>;
|
||||
//
|
||||
// // fn get_target_and_anchor_heights() -> Result<(u32, u32), Self::Error>;
|
||||
//
|
||||
// fn get_address(account: Account) -> Result<String, Self::Error>;
|
||||
//
|
||||
// fn get_balance(account: Account) -> Result<Amount, Self::Error>;
|
||||
|
@ -84,6 +82,8 @@ pub trait DBOps {
|
|||
pub trait CacheOps {
|
||||
type Error;
|
||||
|
||||
fn init_cache(&self) -> Result<(), Self::Error>;
|
||||
|
||||
// Validate the cached chain by applying a function that checks pairwise constraints
|
||||
// (top_block :: &CompactBlock, next_block :: &CompactBlock) -> Result<(), Self::Error)
|
||||
// beginning with the current maximum height walking backward through the chain, terminating
|
||||
|
|
|
@ -59,6 +59,10 @@ impl DataConnection {
|
|||
impl DBOps for DataConnection {
|
||||
type Error = Error<rusqlite::Error>;
|
||||
|
||||
fn init_db(&self) -> Result<(), Self::Error> {
|
||||
init::init_data_database(self).map_err(Error::Database)
|
||||
}
|
||||
|
||||
fn block_height_extrema(&self) -> Result<Option<(BlockHeight, BlockHeight)>, Self::Error> {
|
||||
chain::block_height_extrema(self).map_err(Error::Database)
|
||||
}
|
||||
|
@ -87,6 +91,10 @@ impl CacheConnection {
|
|||
impl CacheOps for CacheConnection {
|
||||
type Error = Error<rusqlite::Error>;
|
||||
|
||||
fn init_cache(&self) -> Result<(), Self::Error> {
|
||||
init::init_cache_database(self).map_err(Error::Database)
|
||||
}
|
||||
|
||||
fn validate_chain<F>(
|
||||
&self,
|
||||
from_height: BlockHeight,
|
||||
|
|
Loading…
Reference in New Issue