zcash_client_backend: Document `data_api::ScannedBlock`

Fixes #885
This commit is contained in:
Kris Nuttycombe 2023-09-20 12:53:45 -06:00
parent 996fea70ac
commit d5dc4c6d9c
1 changed files with 20 additions and 0 deletions

View File

@ -456,6 +456,7 @@ pub struct ScannedBlock<Nf> {
}
impl<Nf> ScannedBlock<Nf> {
/// Constructs a new `ScannedBlock`
pub fn from_parts(
metadata: BlockMetadata,
block_time: u32,
@ -472,34 +473,53 @@ impl<Nf> ScannedBlock<Nf> {
}
}
/// Returns the height of the block that was scanned.
pub fn height(&self) -> BlockHeight {
self.metadata.block_height
}
/// Returns the block hash of the block that was scanned.
pub fn block_hash(&self) -> BlockHash {
self.metadata.block_hash
}
/// Returns the block time of the block that was scanned.
pub fn block_time(&self) -> u32 {
self.block_time
}
/// Returns the metadata describing the state of the note commitment trees as of the end of the
/// scanned block.
///
/// The metadata returned from this method is guaranteed to be consistent with what is returned
/// by [`Self::height`] and [`Self::block_hash`].
pub fn metadata(&self) -> &BlockMetadata {
&self.metadata
}
/// Returns the list of transactions from the block that are relevant to the wallet.
pub fn transactions(&self) -> &[WalletTx<Nf>] {
&self.transactions
}
/// Returns the vector of Sapling nullifiers for each transaction in the block.
///
/// The returned tuple is keyed by both transaction ID and the index of the transaction within
/// the block, so that either the txid or the combination of the block hash available from
/// [`Self::block_hash`] and returned transaction index may be used to uniquely identify the
/// transaction, depending upon the needs of the caller.
pub fn sapling_nullifier_map(&self) -> &[(TxId, u16, Vec<sapling::Nullifier>)] {
&self.sapling_nullifier_map
}
/// Returns the ordered list of Sapling note commitments to be added to the note commitment
/// tree.
pub fn sapling_commitments(&self) -> &[(sapling::Node, Retention<BlockHeight>)] {
&self.sapling_commitments
}
/// Consumes `self` and returns the list of Sapling note commitments associated with the
/// scanned block as an owned value.
pub fn into_sapling_commitments(self) -> Vec<(sapling::Node, Retention<BlockHeight>)> {
self.sapling_commitments
}