pub struct Extension<'a> { /* private fields */ }Expand description
Allows the application of new blocks on top of the txhashset in a
reversible manner within a unit of work provided by the extending
function.
Implementations§
Source§impl<'a> Extension<'a>
impl<'a> Extension<'a>
Sourcepub fn utxo_view(&'a self, header_ext: &'a HeaderExtension<'a>) -> UTXOView<'a>
pub fn utxo_view(&'a self, header_ext: &'a HeaderExtension<'a>) -> UTXOView<'a>
Build a view of the current UTXO set based on the output PMMR and the provided header extension.
Sourcepub fn apply_block(
&mut self,
b: &Block,
batch: &Batch<'_>,
) -> Result<Vec<CommitPos>, Error>
pub fn apply_block( &mut self, b: &Block, batch: &Batch<'_>, ) -> Result<Vec<CommitPos>, Error>
Apply a new block to the current txhashet extension (output, rangeproof, kernel MMRs). Returns a vec of commit_pos representing the pos and height of the outputs spent by this block.
Sourcepub fn merkle_proof(
&self,
output: &OutputIdentifier,
batch: &Batch<'_>,
) -> Result<MerkleProof, Error>
pub fn merkle_proof( &self, output: &OutputIdentifier, batch: &Batch<'_>, ) -> Result<MerkleProof, Error>
Build a Merkle proof for the given output and the block this extension is currently referencing. Note: this relies on the MMR being stable even after pruning/compaction. We need the hash of each sibling pos from the pos up to the peak including the sibling leaf node which may have been removed.
Sourcepub fn snapshot(&mut self, batch: &Batch<'_>) -> Result<(), Error>
pub fn snapshot(&mut self, batch: &Batch<'_>) -> Result<(), Error>
Saves a snapshot of the output and rangeproof MMRs to disk. Specifically - saves a snapshot of the utxo file, tagged with the block hash as filename suffix. Needed for fast-sync (utxo file needs to be rewound before sending across).
Sourcepub fn rewind(
&mut self,
header: &BlockHeader,
batch: &Batch<'_>,
) -> Result<(), Error>
pub fn rewind( &mut self, header: &BlockHeader, batch: &Batch<'_>, ) -> Result<(), Error>
Rewinds the MMRs to the provided block, rewinding to the last output pos and last kernel pos of that block.
Sourcepub fn roots(&self) -> Result<TxHashSetRoots, Error>
pub fn roots(&self) -> Result<TxHashSetRoots, Error>
Current root hashes and sums (if applicable) for the Output, range proof and kernel sum trees.
Sourcepub fn validate_roots(&self, header: &BlockHeader) -> Result<(), Error>
pub fn validate_roots(&self, header: &BlockHeader) -> Result<(), Error>
Validate the MMR (output, rangeproof, kernel) roots against the latest header.
Sourcepub fn validate_sizes(&self, header: &BlockHeader) -> Result<(), Error>
pub fn validate_sizes(&self, header: &BlockHeader) -> Result<(), Error>
Validate the header, output and kernel MMR sizes against the block header.
Sourcepub fn validate_kernel_sums(
&self,
genesis: &BlockHeader,
header: &BlockHeader,
) -> Result<(Commitment, Commitment), Error>
pub fn validate_kernel_sums( &self, genesis: &BlockHeader, header: &BlockHeader, ) -> Result<(Commitment, Commitment), Error>
Validate full kernel sums against the provided header (for overage and kernel_offset). This is an expensive operation as we need to retrieve all the UTXOs and kernels from the respective MMRs. For a significantly faster way of validating full kernel sums see BlockSums.
Sourcepub fn validate(
&self,
genesis: &BlockHeader,
fast_validation: bool,
status: &dyn TxHashsetWriteStatus,
header: &BlockHeader,
) -> Result<(Commitment, Commitment), Error>
pub fn validate( &self, genesis: &BlockHeader, fast_validation: bool, status: &dyn TxHashsetWriteStatus, header: &BlockHeader, ) -> Result<(Commitment, Commitment), Error>
Validate the txhashset state against the provided block header. A “fast validation” will skip rangeproof verification and kernel signature verification.
Sourcepub fn force_rollback(&mut self)
pub fn force_rollback(&mut self)
Force the rollback of this extension, no matter the result
Sourcepub fn dump_output_pmmr(&self)
pub fn dump_output_pmmr(&self)
Dumps the output MMR. We use this after compacting for visual confirmation that it worked.