@@ -225,7 +225,7 @@ where
225
225
pub const ANCHORS_TABLE_NAME : & ' static str = "bdk_anchors" ;
226
226
227
227
/// Initialize sqlite tables.
228
- fn init_sqlite_tables ( db_tx : & rusqlite:: Transaction ) -> rusqlite:: Result < ( ) > {
228
+ pub fn init_sqlite_tables ( db_tx : & rusqlite:: Transaction ) -> rusqlite:: Result < ( ) > {
229
229
let schema_v0: & [ & str ] = & [
230
230
// full transactions
231
231
& format ! (
@@ -264,9 +264,9 @@ where
264
264
}
265
265
266
266
/// Construct a [`TxGraph`] from an sqlite database.
267
+ ///
268
+ /// Remember to call [`Self::init_sqlite_tables`] beforehand.
267
269
pub fn from_sqlite ( db_tx : & rusqlite:: Transaction ) -> rusqlite:: Result < Self > {
268
- Self :: init_sqlite_tables ( db_tx) ?;
269
-
270
270
let mut changeset = Self :: default ( ) ;
271
271
272
272
let mut statement = db_tx. prepare ( & format ! (
@@ -332,9 +332,9 @@ where
332
332
}
333
333
334
334
/// Persist `changeset` to the sqlite database.
335
+ ///
336
+ /// Remember to call [`Self::init_sqlite_tables`] beforehand.
335
337
pub fn persist_to_sqlite ( & self , db_tx : & rusqlite:: Transaction ) -> rusqlite:: Result < ( ) > {
336
- Self :: init_sqlite_tables ( db_tx) ?;
337
-
338
338
let mut statement = db_tx. prepare_cached ( & format ! (
339
339
"INSERT INTO {}(txid, raw_tx) VALUES(:txid, :raw_tx) ON CONFLICT(txid) DO UPDATE SET raw_tx=:raw_tx" ,
340
340
Self :: TXS_TABLE_NAME ,
@@ -396,7 +396,7 @@ impl local_chain::ChangeSet {
396
396
pub const BLOCKS_TABLE_NAME : & ' static str = "bdk_blocks" ;
397
397
398
398
/// Initialize sqlite tables for persisting [`local_chain::LocalChain`].
399
- fn init_sqlite_tables ( db_tx : & rusqlite:: Transaction ) -> rusqlite:: Result < ( ) > {
399
+ pub fn init_sqlite_tables ( db_tx : & rusqlite:: Transaction ) -> rusqlite:: Result < ( ) > {
400
400
let schema_v0: & [ & str ] = & [
401
401
// blocks
402
402
& format ! (
@@ -411,9 +411,9 @@ impl local_chain::ChangeSet {
411
411
}
412
412
413
413
/// Construct a [`LocalChain`](local_chain::LocalChain) from sqlite database.
414
+ ///
415
+ /// Remember to call [`Self::init_sqlite_tables`] beforehand.
414
416
pub fn from_sqlite ( db_tx : & rusqlite:: Transaction ) -> rusqlite:: Result < Self > {
415
- Self :: init_sqlite_tables ( db_tx) ?;
416
-
417
417
let mut changeset = Self :: default ( ) ;
418
418
419
419
let mut statement = db_tx. prepare ( & format ! (
@@ -435,9 +435,9 @@ impl local_chain::ChangeSet {
435
435
}
436
436
437
437
/// Persist `changeset` to the sqlite database.
438
+ ///
439
+ /// Remember to call [`Self::init_sqlite_tables`] beforehand.
438
440
pub fn persist_to_sqlite ( & self , db_tx : & rusqlite:: Transaction ) -> rusqlite:: Result < ( ) > {
439
- Self :: init_sqlite_tables ( db_tx) ?;
440
-
441
441
let mut replace_statement = db_tx. prepare_cached ( & format ! (
442
442
"REPLACE INTO {}(block_height, block_hash) VALUES(:block_height, :block_hash)" ,
443
443
Self :: BLOCKS_TABLE_NAME ,
@@ -471,7 +471,7 @@ impl keychain_txout::ChangeSet {
471
471
472
472
/// Initialize sqlite tables for persisting
473
473
/// [`KeychainTxOutIndex`](keychain_txout::KeychainTxOutIndex).
474
- fn init_sqlite_tables ( db_tx : & rusqlite:: Transaction ) -> rusqlite:: Result < ( ) > {
474
+ pub fn init_sqlite_tables ( db_tx : & rusqlite:: Transaction ) -> rusqlite:: Result < ( ) > {
475
475
let schema_v0: & [ & str ] = & [
476
476
// last revealed
477
477
& format ! (
@@ -487,9 +487,9 @@ impl keychain_txout::ChangeSet {
487
487
488
488
/// Construct [`KeychainTxOutIndex`](keychain_txout::KeychainTxOutIndex) from sqlite database
489
489
/// and given parameters.
490
+ ///
491
+ /// Remember to call [`Self::init_sqlite_tables`] beforehand.
490
492
pub fn from_sqlite ( db_tx : & rusqlite:: Transaction ) -> rusqlite:: Result < Self > {
491
- Self :: init_sqlite_tables ( db_tx) ?;
492
-
493
493
let mut changeset = Self :: default ( ) ;
494
494
495
495
let mut statement = db_tx. prepare ( & format ! (
@@ -511,9 +511,9 @@ impl keychain_txout::ChangeSet {
511
511
}
512
512
513
513
/// Persist `changeset` to the sqlite database.
514
+ ///
515
+ /// Remember to call [`Self::init_sqlite_tables`] beforehand.
514
516
pub fn persist_to_sqlite ( & self , db_tx : & rusqlite:: Transaction ) -> rusqlite:: Result < ( ) > {
515
- Self :: init_sqlite_tables ( db_tx) ?;
516
-
517
517
let mut statement = db_tx. prepare_cached ( & format ! (
518
518
"REPLACE INTO {}(descriptor_id, last_revealed) VALUES(:descriptor_id, :last_revealed)" ,
519
519
Self :: LAST_REVEALED_TABLE_NAME ,
0 commit comments