Struct snarkos_storage::ledger::Ledger[][src]

pub struct Ledger<T: TransactionScheme, P: LoadableMerkleParameters, S: Storage> {
    pub current_block_height: AtomicU32,
    pub ledger_parameters: Arc<P>,
    pub cm_merkle_tree: ArcSwap<MerkleTree<P>>,
    pub storage: S,
    pub _transaction: PhantomData<T>,
}

Fields

current_block_height: AtomicU32ledger_parameters: Arc<P>cm_merkle_tree: ArcSwap<MerkleTree<P>>storage: S_transaction: PhantomData<T>

Implementations

Create a fresh blockchain, optionally at the specified path. Warning: if specified, any existing storage at that location is removed.

Open the blockchain storage at a particular path.

Open the blockchain storage at a particular path as a secondary read-only instance.

Returns true if there are no blocks in the ledger.

Get the latest block height of the chain.

Get the latest number of blocks in the chain.

Get the height of the best block on the chain.

Get the stored old connected peers.

Store the connected peers.

Attempt to catch the secondary read-only storage instance with the primary instance.

Get the latest block in the chain.

Get a block given the block hash.

Get a block given the block number.

Get the block hash given a block number.

Get the block number given a block hash.

Get the list of transaction ids given a block hash.

Find the potential child block hashes given a parent block header.

Returns the block number of a conflicting block that has already been mined.

Remove a block and it’s related data from the storage.

De-commit the latest block and return its header hash.

Remove the latest block.

Remove the latest num_blocks blocks.

Returns true if the block for the given block header hash exists.

Get a block header given the block hash.

Returns true if the block corresponding to this block’s previous_block_hash exists.

Returns the latest shared block header hash. If the block locator hashes are for a side chain, returns the common point of fork. If the block locator hashes are for the canon chain, returns the latest block header hash.

Returns a list of block locator hashes. The purpose of this method is to detect wrong branches in the caller’s canon chain.

Get the block’s path/origin.

Returns the path length and the longest path of children from the given block header

Get the current commitment index

Get the current serial number index

Get the current memo index

Get the current ledger digest

Get the set of past ledger digests

Get serial number index.

Get commitment index

Get memo index

Build a new commitment merkle tree from the stored commitments

Rebuild the stored merkle tree with the current stored commitments

Insert a block into storage without canonizing/committing it.

Commit/canonize a particular block.

Insert a block into the storage and commit as part of the longest chain.

Returns true if the block exists in the canon chain.

Returns true if the block corresponding to this block’s previous_block_hash is in the canon chain.

Revert the chain to the state before the fork.

Get the stored memory pool transactions.

Store the memory pool transactions.

Get all stored record commitments of the node

Get a transaction bytes given the transaction id.

Get a transaction bytes given the transaction id.

Get a transaction bytes given the transaction id.

Removes a record from storage.

Returns a transaction location given the transaction ID if it exists. Returns None otherwise.

Returns a transaction given the transaction ID if it exists. Returns None otherwise.

Returns a transaction in bytes given a transaction ID.

Returns true if the transaction has internal parameters that already exist in the ledger.

Validates the storage of the canon blocks, their child-parent relationships, and their transactions; starts at the current block height and goes down until the genesis block, making sure that the block-related data stored in the database is coherent. The optional limit restricts the number of blocks to check, as it is likely that any issues are applicable only to the last few blocks. The fix argument determines whether the validation process should also attempt to fix the issues it encounters.

Trait Implementations

Instantiates a new ledger with a genesis block.

Returns the number of blocks including the genesis block

Return the parameters used to construct the ledger Merkle tree.

Return a digest of the latest ledger Merkle tree.

Check that st_{ts} is a valid digest for some (past) ledger state.

Returns true if the given commitment exists in the ledger.

Returns true if the given serial number exists in the ledger.

Returns true if the given memo exists in the ledger.

Returns the Merkle path to the latest ledger digest for a given commitment, if it exists in the ledger.

Returns true if the given Merkle path is a valid witness for the given ledger digest and commitment.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Converts self into T using Into<T>. Read more

Causes self to use its Binary implementation when Debug-formatted.

Causes self to use its Display implementation when Debug-formatted. Read more

Causes self to use its LowerExp implementation when Debug-formatted. Read more

Causes self to use its LowerHex implementation when Debug-formatted. Read more

Causes self to use its Octal implementation when Debug-formatted.

Causes self to use its Pointer implementation when Debug-formatted. Read more

Causes self to use its UpperExp implementation when Debug-formatted. Read more

Causes self to use its UpperHex implementation when Debug-formatted. Read more

Performs the conversion.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more

Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Performs the conversion.

Pipes by value. This is generally the method you want to use. Read more

Borrows self and passes that borrow into the pipe function. Read more

Mutably borrows self and passes that borrow into the pipe function. Read more

Borrows self, then passes self.borrow() into the pipe function. Read more

Mutably borrows self, then passes self.borrow_mut() into the pipe function. Read more

Borrows self, then passes self.as_ref() into the pipe function.

Mutably borrows self, then passes self.as_mut() into the pipe function. Read more

Borrows self, then passes self.deref() into the pipe function.

Mutably borrows self, then passes self.deref_mut() into the pipe function. Read more

The alignment of pointer.

The type for initializers.

Initializes a with the given initializer. Read more

Dereferences the given pointer. Read more

Mutably dereferences the given pointer. Read more

Drops the object pointed to by the given pointer. Read more

Should always be Self

Immutable access to a value. Read more

Mutable access to a value. Read more

Immutable access to the Borrow<B> of a value. Read more

Mutable access to the BorrowMut<B> of a value. Read more

Immutable access to the AsRef<R> view of a value. Read more

Mutable access to the AsMut<R> view of a value. Read more

Immutable access to the Deref::Target of a value. Read more

Mutable access to the Deref::Target of a value. Read more

Calls .tap() only in debug builds, and is erased in release builds.

Calls .tap_mut() only in debug builds, and is erased in release builds. Read more

Calls .tap_borrow() only in debug builds, and is erased in release builds. Read more

Calls .tap_borrow_mut() only in debug builds, and is erased in release builds. Read more

Calls .tap_ref() only in debug builds, and is erased in release builds. Read more

Calls .tap_ref_mut() only in debug builds, and is erased in release builds. Read more

Calls .tap_deref() only in debug builds, and is erased in release builds. Read more

Calls .tap_deref_mut() only in debug builds, and is erased in release builds. Read more

Attempts to convert self into T using TryInto<T>. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.