Skip to content

Commit d5173d3

Browse files
authored
snapshot: More Snapshot accessors (#1721)
1 parent 06e5be5 commit d5173d3

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

crates/snapshot/src/lib.rs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -161,17 +161,17 @@ pub struct Snapshot {
161161
version: u8,
162162

163163
/// The address of the snapshotted database.
164-
database_address: Address,
164+
pub database_address: Address,
165165
/// The instance ID of the snapshotted database.
166-
database_instance_id: u64,
166+
pub database_instance_id: u64,
167167

168168
/// ABI version of the module from which this snapshot was created, as [MAJOR, MINOR].
169169
///
170170
/// As of this proposal, [7, 0].
171171
module_abi_version: [u16; 2],
172172

173173
/// The transaction offset of the state this snapshot reflects.
174-
tx_offset: TxOffset,
174+
pub tx_offset: TxOffset,
175175

176176
/// The hashes and reference counts of all objects in the blob store.
177177
blobs: Vec<BlobEntry>,
@@ -450,6 +450,15 @@ impl Snapshot {
450450
.map(|tbl| Self::reconstruct_one_table(object_repo, tbl))
451451
.collect()
452452
}
453+
454+
/// Obtain an iterator over the [`blake3::Hash`]es of all objects
455+
/// this snapshot is referring to.
456+
pub fn objects(&self) -> impl Iterator<Item = blake3::Hash> + '_ {
457+
self.blobs
458+
.iter()
459+
.map(|b| blake3::Hash::from_bytes(b.hash.data))
460+
.chain(self.tables.iter().flat_map(|t| t.pages.iter().copied()))
461+
}
453462
}
454463

455464
/// A repository of snapshots of a particular database instance.

0 commit comments

Comments
 (0)