[][src]Struct grin_chain::txhashset::Extension

pub struct Extension<'a> {
    pub batch: &'a Batch<'a>,
    // some fields omitted
}

Allows the application of new blocks on top of the sum trees in a reversible manner within a unit of work provided by the extending function.

Fields

batch: &'a Batch<'a>

Batch in which the extension occurs, public so it can be used within an extending closure. Just be careful using it that way as it will get rolled back with the extension (i.e on a losing fork).

Methods

impl<'a> Extension<'a>[src]

pub fn head(&self) -> Tip[src]

The head representing the furthest extent of the current extension.

pub fn utxo_view(&'a self, header_ext: &'a HeaderExtension<'a>) -> UTXOView<'a>[src]

Build a view of the current UTXO set based on the output PMMR and the provided header extension.

pub fn apply_block(&mut self, b: &Block) -> Result<(), Error>[src]

Apply a new block to the current txhashet extension (output, rangeproof, kernel MMRs).

pub fn merkle_proof(
    &self,
    output: &OutputIdentifier
) -> Result<MerkleProof, Error>
[src]

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.

pub fn snapshot(&mut self) -> Result<(), Error>[src]

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

pub fn rewind(&mut self, header: &BlockHeader) -> Result<(), Error>[src]

Rewinds the MMRs to the provided block, rewinding to the last output pos and last kernel pos of that block.

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

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

pub fn validate_roots(&self) -> Result<(), Error>[src]

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

pub fn validate_sizes(&self) -> Result<(), Error>[src]

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

pub fn validate_kernel_sums(
    &self,
    genesis: &BlockHeader
) -> Result<(Commitment, Commitment), Error>
[src]

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.

pub fn validate(
    &self,
    genesis: &BlockHeader,
    fast_validation: bool,
    status: &dyn TxHashsetWriteStatus
) -> Result<(Commitment, Commitment), Error>
[src]

Validate the txhashset state against the provided block header. A "fast validation" will skip rangeproof verification and kernel signature verification.

pub fn force_rollback(&mut self)[src]

Force the rollback of this extension, no matter the result

pub fn dump_output_pmmr(&self)[src]

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

pub fn dump(&self, short: bool)[src]

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

pub fn sizes(&self) -> (u64, u64, u64)[src]

Sizes of each of the sum trees

Trait Implementations

impl<'a> Committed for Extension<'a>[src]

Auto Trait Implementations

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

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

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

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

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

Blanket Implementations

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> UnsafeAny for T where
    T: Any

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T> Erased for T

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

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,