From b72251ee28db4f4e511dd8d468ade261ce311966 Mon Sep 17 00:00:00 2001 From: Kris Nuttycombe Date: Tue, 4 Aug 2020 20:49:41 -0600 Subject: [PATCH] Add accounts table initialization. --- zcash_client_backend/src/data_api/mod.rs | 18 +++++++++++------- zcash_client_sqlite/src/lib.rs | 8 ++++++++ 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/zcash_client_backend/src/data_api/mod.rs b/zcash_client_backend/src/data_api/mod.rs index 508cd50d0..c02381956 100644 --- a/zcash_client_backend/src/data_api/mod.rs +++ b/zcash_client_backend/src/data_api/mod.rs @@ -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( + &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, Self::Error>; fn get_block_hash(&self, block_height: BlockHeight) -> Result, Self::Error>; @@ -41,7 +45,7 @@ pub trait DBOps { parameters: &P, block_height: BlockHeight, ) -> Result<(), Self::Error>; - // + // fn get_address(account: Account) -> Result; // // fn get_balance(account: Account) -> Result; diff --git a/zcash_client_sqlite/src/lib.rs b/zcash_client_sqlite/src/lib.rs index c1844b092..e7476a9fc 100644 --- a/zcash_client_sqlite/src/lib.rs +++ b/zcash_client_sqlite/src/lib.rs @@ -63,6 +63,14 @@ impl DBOps for DataConnection { init::init_data_database(self).map_err(Error::Database) } + fn init_accounts( + &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, Self::Error> { chain::block_height_extrema(self).map_err(Error::Database) }