Add accounts table initialization.

This commit is contained in:
Kris Nuttycombe 2020-08-04 20:49:41 -06:00
parent 724fbac33a
commit b72251ee28
2 changed files with 19 additions and 7 deletions

View File

@ -1,5 +1,6 @@
use zcash_primitives::{
block::BlockHash,
consensus::{self, BlockHeight},
//merkle_tree::{CommitmentTree, IncrementalWitness},
//sapling::Node,
//transaction::{
@ -7,8 +8,7 @@ use zcash_primitives::{
// TxId,
// components::Amount,
//},
//zip32::ExtendedFullViewingKey,
consensus::{self, BlockHeight},
zip32::ExtendedFullViewingKey,
};
use crate::proto::compact_formats::CompactBlock;
@ -22,16 +22,20 @@ pub trait DBOps {
// type NoteRef; // Backend-specific note identifier`
fn init_db(&self) -> Result<(), Self::Error>;
//
// fn init_accounts(extfvks: &[ExtendedFullViewingKey]) -> Result<(), Self::Error>;
//
fn init_accounts<P: consensus::Parameters>(
&self,
params: &P,
extfvks: &[ExtendedFullViewingKey],
) -> Result<(), Self::Error>;
// fn init_blocks(
// height: i32,
// hash: BlockHash,
// time: u32,
// sapling_tree: &[u8],
// ) -> Result<(), Self::Error>;
//
fn block_height_extrema(&self) -> Result<Option<(BlockHeight, BlockHeight)>, Self::Error>;
fn get_block_hash(&self, block_height: BlockHeight) -> Result<Option<BlockHash>, Self::Error>;
@ -41,7 +45,7 @@ pub trait DBOps {
parameters: &P,
block_height: BlockHeight,
) -> Result<(), Self::Error>;
//
// fn get_address(account: Account) -> Result<String, Self::Error>;
//
// fn get_balance(account: Account) -> Result<Amount, Self::Error>;

View File

@ -63,6 +63,14 @@ impl DBOps for DataConnection {
init::init_data_database(self).map_err(Error::Database)
}
fn init_accounts<P: consensus::Parameters>(
&self,
params: &P,
extfvks: &[ExtendedFullViewingKey],
) -> Result<(), Self::Error> {
init::init_accounts_table(self, params, extfvks).map_err(|e| e.0)
}
fn block_height_extrema(&self) -> Result<Option<(BlockHeight, BlockHeight)>, Self::Error> {
chain::block_height_extrema(self).map_err(Error::Database)
}