TxHashSet
open
/// Open an existing or new set of backends for the TxHashSet
is_unspent
/// Check if an output is unspent.
/// We look in the index to find the output MMR pos.
/// Then we check the entry in the output MMR and confirm the hash matches.
last_n_output
/// returns the last N nodes inserted into the tree (i.e. the 'bottom'
/// nodes at level 0
/// TODO: These need to return the actual data from the flat-files instead
/// of hashes now
last_n_rangeproof
/// as above, for range proofs
last_n_kernel
/// as above, for kernels
outputs_by_insertion_index
/// returns outputs from the given insertion (leaf) index up to the
/// specified limit. Also returns the last index actually populated
highest_output_insertion_index
/// highest output insertion index available
rangeproofs_by_insertion_index
/// As above, for rangeproofs
roots
/// Get sum tree roots
/// TODO: Return data instead of hashes
merkle_proof
/// build a new merkle proof for the given position
compact
/// Compact the MMR data files and flush the rm logs
Extension
rewind_raw_tx
// Rewind the MMR backend to undo applying a raw tx to the txhashset extension.
// This is used during txpool validation to undo an invalid tx.
apply_raw_tx
/// Apply a "raw" transaction to the txhashset.
/// We will never commit a txhashset extension that includes raw txs.
/// But we can use this when validating txs in the tx pool.
/// If we can add a tx to the tx pool and then successfully add the
/// aggregated tx from the tx pool to the current chain state (via a
/// txhashset extension) then we know the tx pool is valid (including the
/// new tx).
validate_raw_txs
/// Validate a vector of "raw" transactions against the current chain state.
/// We support rewind on a "dirty" txhashset - so we can apply each tx in
/// turn, rewinding if any particular tx is not valid and continuing
/// through the vec of txs provided. This allows us to efficiently apply
/// all the txs, filtering out those that are not valid and returning the
/// final vec of txs that were successfully validated against the txhashset.
///
/// Note: We also pass in a "pre_tx". This tx is applied to and validated
/// before we start applying the vec of txs. We use this when validating
/// txs in the stempool as we need to account for txs in the txpool as
/// well (new_tx + stempool + txpool + txhashset). So we aggregate the
/// contents of the txpool into a single aggregated tx and pass it in here
/// as the "pre_tx" so we apply it to the txhashset before we start
/// validating the stempool txs.
/// This is optional and we pass in None when validating the txpool txs
/// themselves.
verify_coinbase_maturity
/// Verify we are not attempting to spend any coinbase outputs
/// that have not sufficiently matured.
apply_block
/// Apply a new set of blocks on top the existing sum trees. Blocks are
/// applied in order of the provided Vec. If pruning is enabled, inputs also
/// prune MMR data.
save_indexes
// Store all new output pos in the index.
merkle_proof
/// Build a Merkle proof for the given output and the block by
/// rewinding the MMR to the last pos of the block.
/// 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.
snapshot
/// 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).
rewind
/// Rewinds the MMRs to the provided block, rewinding to the last output pos
/// and last kernel pos of that block.
roots
/// Current root hashes and sums (if applicable) for the Output, range proof
/// and kernel sum trees.
validate_roots
/// Validate the various MMR roots against the block header.
validate
/// Validate the txhashset state against the provided block header.
rebuild_index
/// Rebuild the index of MMR positions to the corresponding Output and
/// kernel by iterating over the whole MMR data. This is a costly operation
/// performed only when we receive a full new chain state.
force_rollback
/// Force the rollback of this extension, no matter the result
dump_output_pmmr
/// Dumps the output MMR.
/// We use this after compacting for visual confirmation that it worked.
dump
/// Dumps the state of the 3 sum trees to stdout for debugging. Short
/// version only prints the Output tree.
sizes
/// Sizes of each of the sum trees
verify_kernel_signatures
verify_rangeproofs
validate_kernel_history
/// Special handling to make sure the whole kernel set matches each of its
/// roots in each block header, without truncation. We go back header by
/// header, rewind and check each root. This fixes a potential weakness in
/// fast sync where a reorg past the horizon could allow a whole rewrite of
/// the kernel set.