Skip to content

Commit 1c81cd5

Browse files
committed
refactor(chain)!: change String by &str for versioned scripts in migrate_schema
`&str` is documenting clearly that `migrate_schema` should only read `versioned_strings`. Also, as `schema_vN` methods will return `String`, rust will always automatically deref `&String` to `&str`. BREAKING CHANGE: changes parameter versioned_strings from public function migrate_schema from type &[String] to &[&str].
1 parent 265b59b commit 1c81cd5

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

crates/chain/src/rusqlite_impl.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ fn set_schema_version(
6161
pub fn migrate_schema(
6262
db_tx: &Transaction,
6363
schema_name: &str,
64-
versioned_scripts: &[String],
64+
versioned_scripts: &[&str],
6565
) -> rusqlite::Result<()> {
6666
init_schemas_table(db_tx)?;
6767
let current_version = schema_version(db_tx, schema_name)?;
@@ -269,7 +269,7 @@ impl tx_graph::ChangeSet<ConfirmationBlockTime> {
269269
migrate_schema(
270270
db_tx,
271271
Self::SCHEMA_NAME,
272-
&[Self::schema_v0(), Self::schema_v1()],
272+
&[&Self::schema_v0(), &Self::schema_v1()],
273273
)
274274
}
275275

@@ -435,7 +435,7 @@ impl local_chain::ChangeSet {
435435

436436
/// Initialize sqlite tables for persisting [`local_chain::LocalChain`].
437437
pub fn init_sqlite_tables(db_tx: &rusqlite::Transaction) -> rusqlite::Result<()> {
438-
migrate_schema(db_tx, Self::SCHEMA_NAME, &[Self::schema_v0()])
438+
migrate_schema(db_tx, Self::SCHEMA_NAME, &[&Self::schema_v0()])
439439
}
440440

441441
/// Construct a [`LocalChain`](local_chain::LocalChain) from sqlite database.
@@ -511,7 +511,7 @@ impl keychain_txout::ChangeSet {
511511
/// Initialize sqlite tables for persisting
512512
/// [`KeychainTxOutIndex`](keychain_txout::KeychainTxOutIndex).
513513
pub fn init_sqlite_tables(db_tx: &rusqlite::Transaction) -> rusqlite::Result<()> {
514-
migrate_schema(db_tx, Self::SCHEMA_NAME, &[Self::schema_v0()])
514+
migrate_schema(db_tx, Self::SCHEMA_NAME, &[&Self::schema_v0()])
515515
}
516516

517517
/// Construct [`KeychainTxOutIndex`](keychain_txout::KeychainTxOutIndex) from sqlite database
@@ -635,7 +635,7 @@ mod test {
635635
// Create initial database with v0 sqlite schema
636636
{
637637
let db_tx = conn.transaction()?;
638-
migrate_schema(&db_tx, ChangeSet::SCHEMA_NAME, &[ChangeSet::schema_v0()])?;
638+
migrate_schema(&db_tx, ChangeSet::SCHEMA_NAME, &[&ChangeSet::schema_v0()])?;
639639
db_tx.commit()?;
640640
}
641641

@@ -703,7 +703,7 @@ mod test {
703703
migrate_schema(
704704
&db_tx,
705705
ChangeSet::SCHEMA_NAME,
706-
&[ChangeSet::schema_v0(), ChangeSet::schema_v1()],
706+
&[&ChangeSet::schema_v0(), &ChangeSet::schema_v1()],
707707
)?;
708708
db_tx.commit()?;
709709
}

crates/wallet/src/wallet/changeset.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ impl ChangeSet {
9090
crate::rusqlite_impl::migrate_schema(
9191
db_tx,
9292
Self::WALLET_SCHEMA_NAME,
93-
&[Self::schema_v0()],
93+
&[&Self::schema_v0()],
9494
)?;
9595

9696
bdk_chain::local_chain::ChangeSet::init_sqlite_tables(db_tx)?;

0 commit comments

Comments
 (0)