pub struct ChangeSet {
pub last_revealed: BTreeMap<DescriptorId, u32>,
pub spk_cache: BTreeMap<DescriptorId, BTreeMap<u32, ScriptBuf>>,
}Expand description
ChangeSet represents persistent updates to a KeychainTxOutIndex.
It tracks:
last_revealed: the highest derivation index revealed per descriptor.spk_cache: the cache of derived script pubkeys to persist across runs.
You can apply a ChangeSet to a KeychainTxOutIndex via
KeychainTxOutIndex::apply_changeset, or merge two change sets with ChangeSet::merge.
§Monotonicity
last_revealedis monotonic: merging retains the maximum index for each descriptor and never decreases.spk_cacheaccumulates entries: once a script pubkey is persisted, it remains available for reload. If the same descriptor and index appear again with a new script pubkey, the latter value overrides the former.
Fields§
§last_revealed: BTreeMap<DescriptorId, u32>Maps each DescriptorId to its last revealed derivation index.
spk_cache: BTreeMap<DescriptorId, BTreeMap<u32, ScriptBuf>>Cache of derived script pubkeys to persist, keyed by descriptor ID and derivation index
(u32).
Implementations§
Source§impl ChangeSet
impl ChangeSet
Sourcepub const SCHEMA_NAME: &'static str = "bdk_keychaintxout"
pub const SCHEMA_NAME: &'static str = "bdk_keychaintxout"
Schema name for the changeset.
Sourcepub const LAST_REVEALED_TABLE_NAME: &'static str = "bdk_descriptor_last_revealed"
pub const LAST_REVEALED_TABLE_NAME: &'static str = "bdk_descriptor_last_revealed"
Name for table that stores last revealed indices per descriptor id.
Sourcepub const DERIVED_SPKS_TABLE_NAME: &'static str = "bdk_descriptor_derived_spks"
pub const DERIVED_SPKS_TABLE_NAME: &'static str = "bdk_descriptor_derived_spks"
Name for table that stores derived spks.
Sourcepub fn schema_v0() -> String
pub fn schema_v0() -> String
Get v0 of sqlite keychain_txout::ChangeSet schema
Sourcepub fn schema_v1() -> String
pub fn schema_v1() -> String
Get v1 of sqlite keychain_txout::ChangeSet schema
Sourcepub fn init_sqlite_tables(db_tx: &Transaction<'_>) -> Result<()>
pub fn init_sqlite_tables(db_tx: &Transaction<'_>) -> Result<()>
Initialize sqlite tables for persisting
KeychainTxOutIndex.
Sourcepub fn from_sqlite(db_tx: &Transaction<'_>) -> Result<Self>
pub fn from_sqlite(db_tx: &Transaction<'_>) -> Result<Self>
Construct KeychainTxOutIndex from sqlite database
and given parameters.
Remember to call Self::init_sqlite_tables beforehand.
Sourcepub fn persist_to_sqlite(&self, db_tx: &Transaction<'_>) -> Result<()>
pub fn persist_to_sqlite(&self, db_tx: &Transaction<'_>) -> Result<()>
Persist changeset to the sqlite database.
Remember to call Self::init_sqlite_tables beforehand.