Struct Extension

Source
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>

Source

pub fn head(&self) -> Tip

The head representing the furthest extent of the current extension.

Source

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.

Source

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.

Source

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.

Source

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).

Source

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.

Source

pub fn roots(&self) -> Result<TxHashSetRoots, Error>

Current root hashes and sums (if applicable) for the Output, range proof and kernel sum trees.

Source

pub fn validate_roots(&self, header: &BlockHeader) -> Result<(), Error>

Validate the MMR (output, rangeproof, kernel) roots against the latest header.

Source

pub fn validate_sizes(&self, header: &BlockHeader) -> Result<(), Error>

Validate the header, output and kernel MMR sizes against the block header.

Source

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.

Source

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.

Source

pub fn force_rollback(&mut self)

Force the rollback of this extension, no matter the result

Source

pub fn dump_output_pmmr(&self)

Dumps the output MMR. We use this after compacting for visual confirmation that it worked.

Source

pub fn dump(&self, short: bool)

Dumps the state of the 3 sum trees to stdout for debugging. Short version only prints the Output tree.

Source

pub fn sizes(&self) -> (u64, u64, u64)

Sizes of each of the sum trees

Trait Implementations§

Source§

impl<'a> Committed for Extension<'a>

Source§

fn inputs_committed(&self) -> Vec<Commitment>

Vector of input commitments to verify.
Source§

fn outputs_committed(&self) -> Vec<Commitment>

Vector of output commitments to verify.
Source§

fn kernels_committed(&self) -> Vec<Commitment>

Vector of kernel excesses to verify.
Source§

fn sum_kernel_excesses( &self, offset: &BlindingFactor, ) -> Result<(Commitment, Commitment), Error>

Gather the kernel excesses and sum them.
Source§

fn sum_commitments(&self, overage: i64) -> Result<Commitment, Error>

Gathers commitments and sum them.
Source§

fn verify_kernel_sums( &self, overage: i64, kernel_offset: BlindingFactor, ) -> Result<(Commitment, Commitment), Error>

Verify the sum of the kernel excesses equals the sum of the outputs, taking into account both the kernel_offset and overage.

Auto Trait Implementations§

§

impl<'a> Freeze for Extension<'a>

§

impl<'a> RefUnwindSafe for Extension<'a>

§

impl<'a> Send for Extension<'a>

§

impl<'a> Sync for Extension<'a>

§

impl<'a> Unpin for Extension<'a>

§

impl<'a> !UnwindSafe for Extension<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> SafeBorrow<T> for T
where T: ?Sized,

Source§

fn borrow_replacement(ptr: &T) -> &T

Given ptr, which was obtained from a prior call to Self::borrow(), return a value with the same nominal lifetime which is guaranteed to survive mutations to Self. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> Erased for T

Source§

impl<T> UnsafeAny for T
where T: Any,