From bf85a28ec13ac5cae83ef6f79413c12d583a9a79 Mon Sep 17 00:00:00 2001 From: Kris Nuttycombe Date: Thu, 26 Jan 2023 14:33:50 -0700 Subject: [PATCH] Add a note about metadata database initialization to `FsBlockDb::for_path` Fixes #748 --- zcash_client_sqlite/src/chain/init.rs | 3 +++ zcash_client_sqlite/src/lib.rs | 7 ++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/zcash_client_sqlite/src/chain/init.rs b/zcash_client_sqlite/src/chain/init.rs index 8bb40aec4..53f6d50ae 100644 --- a/zcash_client_sqlite/src/chain/init.rs +++ b/zcash_client_sqlite/src/chain/init.rs @@ -37,6 +37,9 @@ pub fn init_cache_database(db_cache: &BlockDb) -> Result<(), rusqlite::Error> { /// Sets up the internal structure of the metadata cache database. /// +/// This will automatically apply any available migrations that have not yet been applied to the +/// database as part of its operation. +/// /// # Examples /// /// ``` diff --git a/zcash_client_sqlite/src/lib.rs b/zcash_client_sqlite/src/lib.rs index ed2772f63..bc0b71781 100644 --- a/zcash_client_sqlite/src/lib.rs +++ b/zcash_client_sqlite/src/lib.rs @@ -627,7 +627,7 @@ impl<'a, P: consensus::Parameters> WalletWrite for DataConnStmtCache<'a, P> { let nullifiers = self.wallet_db.get_all_nullifiers()?; // If the transaction contains shielded spends from our wallet, we will store z->t // transactions we observe in the same way they would be stored by - // create_spend_to_address. + // create_spend_to_address. if let Some((account_id, _)) = nullifiers.iter().find( |(_, nf)| d_tx.tx.sapling_bundle().iter().flat_map(|b| b.shielded_spends().iter()) @@ -883,6 +883,11 @@ impl FsBlockDb { /// `/blockmeta.sqlite` and will ensure that a directory exists at /// `/blocks` where this block store will expect to find serialized block /// files as described for [`FsBlockDb`]. + /// + /// An application using this constructor should ensure that they call + /// [`zcash_client_sqlite::chain::init::init_blockmetadb`] at application startup to ensure + /// that the resulting metadata database is properly initialized and has had all required + /// migrations applied before use. pub fn for_path>(fsblockdb_root: P) -> Result { let meta = fs::metadata(&fsblockdb_root).map_err(FsBlockDbError::Fs)?; if meta.is_dir() {