pub struct Chain {
network: Network,
inner: ChainInner,
pub(super) last_fork_height: Option<Height>,
detached_index_entries: BTreeMap<Height, usize>,
pub(crate) index_removals_since_rebuild: usize,
}Expand description
A single non-finalized partial chain, from the child of the finalized tip, to a non-finalized chain tip.
Fields§
§network: NetworkThe configured network for this chain.
inner: ChainInnerThe internal state of this chain.
last_fork_height: Option<Height>The last height this chain forked at. Diagnostics only.
This field is only used for metrics. It is not consensus-critical, and it is not checked for equality.
We keep the same last fork height in both sides of a clone, because every new block clones a chain, even if it’s just growing that chain.
§Note
Most diagnostics are implemented on the NonFinalizedState, rather than each chain. Some
diagnostics only use the best chain, and others need to modify the Chain state, but that’s
difficult with Arc<Chain>s.
detached_index_entries: BTreeMap<Height, usize>Estimates of the transaction, spend, and nullifier entries this chain no longer shares with other chains, because it removed blocks from its maps separately from them, or rebuilt them. Keyed by the chain’s tip height when the entries were detached.
Once the chain finalizes past that height, it has removed every entry it held at the time, rewriting the map paths it detached, so the estimate is retired.
It is not checked for equality.
index_removals_since_rebuild: usizeThe transaction, spend, and nullifier entries this chain removed separately from the best chain since it last rebuilt its maps from it.
It is not checked for equality.
Implementations§
Source§impl Chain
impl Chain
Sourcepub(crate) fn new(
network: &Network,
finalized_tip_height: Height,
note_commitment_trees: NoteCommitmentTrees,
history_tree: Arc<HistoryTree>,
finalized_tip_chain_value_pools: ValueBalance<NonNegative>,
) -> Self
pub(crate) fn new( network: &Network, finalized_tip_height: Height, note_commitment_trees: NoteCommitmentTrees, history_tree: Arc<HistoryTree>, finalized_tip_chain_value_pools: ValueBalance<NonNegative>, ) -> Self
Create a new Chain with the given finalized tip trees and network.
The subtree fields of note_commitment_trees are unused: a forked chain starts tracking
subtrees from empty and fills them from its own block commits.
Sourcepub fn eq_internal_state(&self, other: &Chain) -> bool
pub fn eq_internal_state(&self, other: &Chain) -> bool
Is the internal state of self the same as other?
Chain has custom Eq and Ord implementations based on proof of work,
which are used to select the best chain. So we can’t derive Eq for Chain.
Unlike the custom trait impls, this method returns true if the entire internal state
of two chains is equal.
If the internal states are different, it returns false,
even if the blocks in the two chains are equal.
Sourcepub fn recent_fork_height(&self) -> Option<Height>
pub fn recent_fork_height(&self) -> Option<Height>
Returns the last fork height if that height is still in the non-finalized state.
Otherwise, if that fork has been finalized, returns None.
Sourcepub fn recent_fork_length(&self) -> Option<u32>
pub fn recent_fork_length(&self) -> Option<u32>
Returns this chain fork’s length, if its fork is still in the non-finalized state.
Otherwise, if the fork has been finalized, returns None.
Sourcepub fn push(
self,
block: ContextuallyVerifiedBlock,
) -> Result<Chain, ValidateContextError>
pub fn push( self, block: ContextuallyVerifiedBlock, ) -> Result<Chain, ValidateContextError>
Push a contextually valid non-finalized block into this chain as the new tip.
If the block is invalid, drops this chain, and returns an error.
The state service must also complete its other contextual checks, including reserve-funded
subsidy and miner fees. This method validates the chain updates in
Self::update_chain_tip_with; success alone does not establish contextual validity.
Sourcepub(crate) fn push_with_trees(
self,
block: ContextuallyVerifiedBlock,
precomputed: Option<&PrecomputedTrees>,
) -> Result<Chain, ValidateContextError>
pub(crate) fn push_with_trees( self, block: ContextuallyVerifiedBlock, precomputed: Option<&PrecomputedTrees>, ) -> Result<Chain, ValidateContextError>
Pushes block like Self::push, reusing the precomputed note commitment trees if
they were computed from the same block body and this chain’s tip trees.
Sourcepub(crate) fn pop_root(&mut self) -> (Arc<ContextuallyVerifiedBlock>, Treestate)
pub(crate) fn pop_root(&mut self) -> (Arc<ContextuallyVerifiedBlock>, Treestate)
Pops the lowest height block of the non-finalized portion of a chain, and returns it with its associated treestate.
Sourcepub fn child_blocks(
&self,
block_height: &Height,
) -> Vec<ContextuallyVerifiedBlock>
pub fn child_blocks( &self, block_height: &Height, ) -> Vec<ContextuallyVerifiedBlock>
Returns the block at the provided height and all of its descendant blocks.
Sourcepub fn invalidate_block(
&self,
block_hash: Hash,
) -> Option<(Self, Vec<ContextuallyVerifiedBlock>)>
pub fn invalidate_block( &self, block_hash: Hash, ) -> Option<(Self, Vec<ContextuallyVerifiedBlock>)>
Returns a new chain without the invalidated block or its descendants.
Sourcepub fn non_finalized_root_height(&self) -> Height
pub fn non_finalized_root_height(&self) -> Height
Returns the height of the chain root.
Sourcepub fn fork(&self, fork_tip: Hash) -> Option<Self>
pub fn fork(&self, fork_tip: Hash) -> Option<Self>
Fork and return a chain at the block with the given fork_tip, if it is part of this
chain. Otherwise, if this chain does not contain fork_tip, returns None.
Sourcepub fn block(
&self,
hash_or_height: HashOrHeight,
) -> Option<&ContextuallyVerifiedBlock>
pub fn block( &self, hash_or_height: HashOrHeight, ) -> Option<&ContextuallyVerifiedBlock>
Returns the ContextuallyVerifiedBlock with block::Hash or
Height, if it exists in this chain.
Sourcepub fn transaction(
&self,
hash: Hash,
) -> Option<(&Arc<Transaction>, Height, DateTime<Utc>)>
pub fn transaction( &self, hash: Hash, ) -> Option<(&Arc<Transaction>, Height, DateTime<Utc>)>
Returns the Transaction with transaction::Hash, if it exists in this chain.
Sourcepub fn transaction_by_loc(
&self,
tx_loc: TransactionLocation,
) -> Option<&Arc<Transaction>>
pub fn transaction_by_loc( &self, tx_loc: TransactionLocation, ) -> Option<&Arc<Transaction>>
Returns the Transaction at TransactionLocation, if it exists in this chain.
Sourcepub fn transaction_hash_by_loc(
&self,
tx_loc: TransactionLocation,
) -> Option<&Hash>
pub fn transaction_hash_by_loc( &self, tx_loc: TransactionLocation, ) -> Option<&Hash>
Returns the transaction::Hash for the transaction at TransactionLocation,
if it exists in this chain.
Sourcepub fn transaction_hashes_for_block(
&self,
hash_or_height: HashOrHeight,
) -> Option<Arc<[Hash]>>
pub fn transaction_hashes_for_block( &self, hash_or_height: HashOrHeight, ) -> Option<Arc<[Hash]>>
Returns the transaction::Hashes in the block with hash_or_height,
if it exists in this chain.
Hashes are returned in block order.
Returns None if the block is not found.
Sourcepub fn hash_by_height(&self, height: Height) -> Option<Hash>
pub fn hash_by_height(&self, height: Height) -> Option<Hash>
Returns the block::Hash for height, if it exists in this chain.
Sourcepub fn height_by_hash(&self, hash: Hash) -> Option<Height>
pub fn height_by_hash(&self, hash: Hash) -> Option<Height>
Returns the Height for hash, if it exists in this chain.
Sourcepub fn contains_block_hash(&self, hash: Hash) -> bool
pub fn contains_block_hash(&self, hash: Hash) -> bool
Returns true is the chain contains the given block hash. Returns false otherwise.
Sourcepub fn contains_block_height(&self, height: Height) -> bool
pub fn contains_block_height(&self, height: Height) -> bool
Returns true is the chain contains the given block height. Returns false otherwise.
Sourcepub fn contains_hash_or_height(
&self,
hash_or_height: impl Into<HashOrHeight>,
) -> bool
pub fn contains_hash_or_height( &self, hash_or_height: impl Into<HashOrHeight>, ) -> bool
Returns true is the chain contains the given block hash or height. Returns false otherwise.
Sourcepub fn non_finalized_tip(&self) -> (Height, Hash)
pub fn non_finalized_tip(&self) -> (Height, Hash)
Returns the non-finalized tip block height and hash.
Sourcepub fn non_finalized_tip_with_value_balance(
&self,
) -> (Height, Hash, ValueBalance<NonNegative>)
pub fn non_finalized_tip_with_value_balance( &self, ) -> (Height, Hash, ValueBalance<NonNegative>)
Returns the non-finalized tip block height, hash, and total pool value balances.
Sourcepub fn block_info(&self, hash_or_height: HashOrHeight) -> Option<BlockInfo>
pub fn block_info(&self, hash_or_height: HashOrHeight) -> Option<BlockInfo>
Returns the total pool balance after the block specified by
HashOrHeight, if it exists in the non-finalized Chain.
Sourcepub fn sprout_note_commitment_tree_for_tip(&self) -> Arc<NoteCommitmentTree> ⓘ
pub fn sprout_note_commitment_tree_for_tip(&self) -> Arc<NoteCommitmentTree> ⓘ
Returns the Sprout note commitment tree of the tip of this Chain,
including all finalized notes, and the non-finalized notes in this chain.
If the chain is empty, instead returns the tree of the finalized tip,
which was supplied in Chain::new()
§Panics
If this chain has no sprout trees. (This should be impossible.)
Sourcepub fn sprout_tree(
&self,
hash_or_height: HashOrHeight,
) -> Option<Arc<NoteCommitmentTree>>
pub fn sprout_tree( &self, hash_or_height: HashOrHeight, ) -> Option<Arc<NoteCommitmentTree>>
Returns the Sprout NoteCommitmentTree specified by
a HashOrHeight, if it exists in the non-finalized Chain.
Sourcefn add_sprout_tree_and_anchor(
&mut self,
height: Height,
tree: Arc<NoteCommitmentTree>,
)
fn add_sprout_tree_and_anchor( &mut self, height: Height, tree: Arc<NoteCommitmentTree>, )
Adds the Sprout tree to the tree and anchor indexes at height.
height can be either:
- the height of a new block that has just been added to the chain tip, or
- the finalized tip height—the height of the parent of the first block of a new chain.
Stores only the first tree in each series of identical trees.
§Panics
- If there’s a tree already stored at
height. - If there’s an anchor already stored at
height.
Sourcefn remove_sprout_tree_and_anchor(
&mut self,
position: RevertPosition,
height: Height,
)
fn remove_sprout_tree_and_anchor( &mut self, position: RevertPosition, height: Height, )
Removes the Sprout tree and anchor indexes at height.
height can be at two different RevertPositions in the chain:
-
a tip block above a chain fork—only the tree and anchor at that height are removed, or
-
a root block—all trees and anchors at and below that height are removed, including temporary finalized tip trees.
§Panics
-
If the anchor being removed is not present.
-
If there is no tree at
height.
Sourcepub fn sapling_note_commitment_tree_for_tip(&self) -> Arc<NoteCommitmentTree> ⓘ
pub fn sapling_note_commitment_tree_for_tip(&self) -> Arc<NoteCommitmentTree> ⓘ
Returns the Sapling note commitment tree of the tip of this Chain,
including all finalized notes, and the non-finalized notes in this chain.
If the chain is empty, instead returns the tree of the finalized tip,
which was supplied in Chain::new()
§Panics
If this chain has no sapling trees. (This should be impossible.)
Sourcepub fn sapling_tree(
&self,
hash_or_height: HashOrHeight,
) -> Option<Arc<NoteCommitmentTree>>
pub fn sapling_tree( &self, hash_or_height: HashOrHeight, ) -> Option<Arc<NoteCommitmentTree>>
Returns the Sapling NoteCommitmentTree specified
by a HashOrHeight, if it exists in the non-finalized Chain.
Sourcepub fn sapling_subtree(
&self,
hash_or_height: HashOrHeight,
) -> Option<NoteCommitmentSubtree<Node>>
pub fn sapling_subtree( &self, hash_or_height: HashOrHeight, ) -> Option<NoteCommitmentSubtree<Node>>
Returns the Sapling NoteCommitmentSubtree that was completed at a block with
HashOrHeight, if it exists in the non-finalized Chain.
§Concurrency
This method should not be used to get subtrees in concurrent code by height, because the same heights in different chain forks can have different subtrees.
Sourcepub fn sapling_subtrees_in_range(
&self,
range: impl RangeBounds<NoteCommitmentSubtreeIndex>,
) -> BTreeMap<NoteCommitmentSubtreeIndex, NoteCommitmentSubtreeData<Node>>
pub fn sapling_subtrees_in_range( &self, range: impl RangeBounds<NoteCommitmentSubtreeIndex>, ) -> BTreeMap<NoteCommitmentSubtreeIndex, NoteCommitmentSubtreeData<Node>>
Returns a list of Sapling NoteCommitmentSubtrees in the provided range.
Unlike the finalized state and ReadRequest::SaplingSubtrees, the returned subtrees
can start after start_index. These subtrees are continuous up to the tip.
There is no API for retrieving single subtrees by index, because it can accidentally be used to create an inconsistent list of subtrees after concurrent non-finalized and finalized updates.
Sourcepub fn sapling_subtree_for_tip(&self) -> Option<NoteCommitmentSubtree<Node>>
pub fn sapling_subtree_for_tip(&self) -> Option<NoteCommitmentSubtree<Node>>
Returns the Sapling NoteCommitmentSubtree if it was completed at the tip height.
Sourcefn add_sapling_tree_and_anchor(
&mut self,
height: Height,
tree: Arc<NoteCommitmentTree>,
)
fn add_sapling_tree_and_anchor( &mut self, height: Height, tree: Arc<NoteCommitmentTree>, )
Adds the Sapling tree to the tree and anchor indexes at height.
height can be either:
- the height of a new block that has just been added to the chain tip, or
- the finalized tip height—the height of the parent of the first block of a new chain.
Stores only the first tree in each series of identical trees.
§Panics
- If there’s a tree already stored at
height. - If there’s an anchor already stored at
height.
Sourcefn remove_sapling_tree_and_anchor(
&mut self,
position: RevertPosition,
height: Height,
)
fn remove_sapling_tree_and_anchor( &mut self, position: RevertPosition, height: Height, )
Removes the Sapling tree and anchor indexes at height.
height can be at two different RevertPositions in the chain:
-
a tip block above a chain fork—only the tree and anchor at that height are removed, or
-
a root block—all trees and anchors at and below that height are removed, including temporary finalized tip trees.
§Panics
-
If the anchor being removed is not present.
-
If there is no tree at
height.
Sourcepub fn orchard_note_commitment_tree_for_tip(&self) -> Arc<NoteCommitmentTree> ⓘ
pub fn orchard_note_commitment_tree_for_tip(&self) -> Arc<NoteCommitmentTree> ⓘ
Returns the Orchard note commitment tree of the tip of this Chain,
including all finalized notes, and the non-finalized notes in this chain.
If the chain is empty, instead returns the tree of the finalized tip,
which was supplied in Chain::new()
§Panics
If this chain has no orchard trees. (This should be impossible.)
Sourcepub fn orchard_tree(
&self,
hash_or_height: HashOrHeight,
) -> Option<Arc<NoteCommitmentTree>>
pub fn orchard_tree( &self, hash_or_height: HashOrHeight, ) -> Option<Arc<NoteCommitmentTree>>
Returns the Orchard
NoteCommitmentTree specified by a
HashOrHeight, if it exists in the non-finalized Chain.
Sourcepub fn orchard_subtree(
&self,
hash_or_height: HashOrHeight,
) -> Option<NoteCommitmentSubtree<Node>>
pub fn orchard_subtree( &self, hash_or_height: HashOrHeight, ) -> Option<NoteCommitmentSubtree<Node>>
Returns the Orchard NoteCommitmentSubtree that was completed at a block with
HashOrHeight, if it exists in the non-finalized Chain.
§Concurrency
This method should not be used to get subtrees in concurrent code by height, because the same heights in different chain forks can have different subtrees.
Sourcepub fn orchard_subtrees_in_range(
&self,
range: impl RangeBounds<NoteCommitmentSubtreeIndex>,
) -> BTreeMap<NoteCommitmentSubtreeIndex, NoteCommitmentSubtreeData<Node>>
pub fn orchard_subtrees_in_range( &self, range: impl RangeBounds<NoteCommitmentSubtreeIndex>, ) -> BTreeMap<NoteCommitmentSubtreeIndex, NoteCommitmentSubtreeData<Node>>
Returns a list of Orchard NoteCommitmentSubtrees in the provided range.
Unlike the finalized state and ReadRequest::OrchardSubtrees, the returned subtrees
can start after start_index. These subtrees are continuous up to the tip.
There is no API for retrieving single subtrees by index, because it can accidentally be used to create an inconsistent list of subtrees after concurrent non-finalized and finalized updates.
Sourcepub fn orchard_subtree_for_tip(&self) -> Option<NoteCommitmentSubtree<Node>>
pub fn orchard_subtree_for_tip(&self) -> Option<NoteCommitmentSubtree<Node>>
Returns the Orchard NoteCommitmentSubtree if it was completed at the tip height.
Sourcefn add_orchard_tree_and_anchor(
&mut self,
height: Height,
tree: Arc<NoteCommitmentTree>,
)
fn add_orchard_tree_and_anchor( &mut self, height: Height, tree: Arc<NoteCommitmentTree>, )
Adds the Orchard tree to the tree and anchor indexes at height.
height can be either:
- the height of a new block that has just been added to the chain tip, or
- the finalized tip height—the height of the parent of the first block of a new chain.
Stores only the first tree in each series of identical trees.
§Panics
- If there’s a tree already stored at
height. - If there’s an anchor already stored at
height.
Sourcefn remove_orchard_tree_and_anchor(
&mut self,
position: RevertPosition,
height: Height,
)
fn remove_orchard_tree_and_anchor( &mut self, position: RevertPosition, height: Height, )
Removes the Orchard tree and anchor indexes at height.
height can be at two different RevertPositions in the chain:
-
a tip block above a chain fork—only the tree and anchor at that height are removed, or
-
a root block—all trees and anchors at and below that height are removed, including temporary finalized tip trees.
§Panics
-
If the anchor being removed is not present.
-
If there is no tree at
height.
Sourcefn add_note_commitment_tree_and_anchor(
pool: &'static str,
trees_by_height: &mut BTreeMap<Height, Arc<NoteCommitmentTree>>,
anchors_by_height: &mut BTreeMap<Height, Root>,
anchors: &mut MultiSet<Root>,
height: Height,
tree: Arc<NoteCommitmentTree>,
prev_tree: Option<Arc<NoteCommitmentTree>>,
)
fn add_note_commitment_tree_and_anchor( pool: &'static str, trees_by_height: &mut BTreeMap<Height, Arc<NoteCommitmentTree>>, anchors_by_height: &mut BTreeMap<Height, Root>, anchors: &mut MultiSet<Root>, height: Height, tree: Arc<NoteCommitmentTree>, prev_tree: Option<Arc<NoteCommitmentTree>>, )
Shared implementation of add_{orchard,ironwood}_tree_and_anchor.
Ironwood reuses the Orchard note commitment tree and root types, so the two pools index into
identically-typed maps; only the target fields and the pool log/panic label differ.
prev_tree is the tree at the previous height (None at the minimum height).
Sourcefn remove_note_commitment_tree_and_anchor(
pool: &'static str,
trees_by_height: &mut BTreeMap<Height, Arc<NoteCommitmentTree>>,
anchors_by_height: &mut BTreeMap<Height, Root>,
anchors: &mut MultiSet<Root>,
position: RevertPosition,
height: Height,
highest_removed_tree: Option<Arc<NoteCommitmentTree>>,
non_finalized_tip_height: Option<Height>,
)
fn remove_note_commitment_tree_and_anchor( pool: &'static str, trees_by_height: &mut BTreeMap<Height, Arc<NoteCommitmentTree>>, anchors_by_height: &mut BTreeMap<Height, Root>, anchors: &mut MultiSet<Root>, position: RevertPosition, height: Height, highest_removed_tree: Option<Arc<NoteCommitmentTree>>, non_finalized_tip_height: Option<Height>, )
Shared implementation of remove_{orchard,ironwood}_tree_and_anchor.
highest_removed_tree is the tree at height cached before removal (only needed for
RevertPosition::Root); non_finalized_tip_height is None when the chain is empty.
Sourcepub fn ironwood_note_commitment_tree_for_tip(&self) -> Arc<NoteCommitmentTree> ⓘ
pub fn ironwood_note_commitment_tree_for_tip(&self) -> Arc<NoteCommitmentTree> ⓘ
Sourcepub fn ironwood_tree(
&self,
hash_or_height: HashOrHeight,
) -> Option<Arc<NoteCommitmentTree>>
pub fn ironwood_tree( &self, hash_or_height: HashOrHeight, ) -> Option<Arc<NoteCommitmentTree>>
Returns the Ironwood NoteCommitmentTree specified by
a HashOrHeight, if it exists in the non-finalized Chain.
Sourcepub fn ironwood_subtree(
&self,
hash_or_height: HashOrHeight,
) -> Option<NoteCommitmentSubtree<Node>>
pub fn ironwood_subtree( &self, hash_or_height: HashOrHeight, ) -> Option<NoteCommitmentSubtree<Node>>
Returns the Ironwood NoteCommitmentSubtree that was completed at a block with
HashOrHeight, if it exists in the non-finalized Chain.
Sourcepub fn ironwood_subtrees_in_range(
&self,
range: impl RangeBounds<NoteCommitmentSubtreeIndex>,
) -> BTreeMap<NoteCommitmentSubtreeIndex, NoteCommitmentSubtreeData<Node>>
pub fn ironwood_subtrees_in_range( &self, range: impl RangeBounds<NoteCommitmentSubtreeIndex>, ) -> BTreeMap<NoteCommitmentSubtreeIndex, NoteCommitmentSubtreeData<Node>>
Returns a list of Ironwood NoteCommitmentSubtrees in the provided range.
Sourcepub fn ironwood_subtree_for_tip(&self) -> Option<NoteCommitmentSubtree<Node>>
pub fn ironwood_subtree_for_tip(&self) -> Option<NoteCommitmentSubtree<Node>>
Returns the Ironwood NoteCommitmentSubtree if it was completed at the tip height.
Sourcefn add_ironwood_tree_and_anchor(
&mut self,
height: Height,
tree: Arc<NoteCommitmentTree>,
)
fn add_ironwood_tree_and_anchor( &mut self, height: Height, tree: Arc<NoteCommitmentTree>, )
Adds the Ironwood tree to the tree and anchor indexes at height.
See Chain::add_orchard_tree_and_anchor for the height semantics and invariants.
Sourcefn remove_ironwood_tree_and_anchor(
&mut self,
position: RevertPosition,
height: Height,
)
fn remove_ironwood_tree_and_anchor( &mut self, position: RevertPosition, height: Height, )
Removes the Ironwood tree and anchor indexes at height.
See Chain::remove_orchard_tree_and_anchor for the revert-position semantics and invariants.
Sourcepub fn history_block_commitment_tree(&self) -> Arc<HistoryTree> ⓘ
pub fn history_block_commitment_tree(&self) -> Arc<HistoryTree> ⓘ
Returns the History tree of the tip of this Chain,
including all finalized blocks, and the non-finalized blocks below the chain tip.
If the chain is empty, instead returns the tree of the finalized tip,
which was supplied in Chain::new()
§Panics
If this chain has no history trees. (This should be impossible.)
Sourcepub fn history_tree(
&self,
hash_or_height: HashOrHeight,
) -> Option<Arc<HistoryTree>>
pub fn history_tree( &self, hash_or_height: HashOrHeight, ) -> Option<Arc<HistoryTree>>
Returns the HistoryTree specified by a HashOrHeight, if it
exists in the non-finalized Chain.
Sourcefn add_history_tree(&mut self, height: Height, tree: Arc<HistoryTree>)
fn add_history_tree(&mut self, height: Height, tree: Arc<HistoryTree>)
Add the History tree to the history tree index at height.
height can be either:
- the height of a new block that has just been added to the chain tip, or
- the finalized tip height: the height of the parent of the first block of a new chain.
Sourcefn remove_history_tree(&mut self, position: RevertPosition, height: Height)
fn remove_history_tree(&mut self, position: RevertPosition, height: Height)
Remove the History tree index at height.
height can be at two different RevertPositions in the chain:
- a tip block above a chain fork: only that height is removed, or
- a root block: all trees below that height are removed, including temporary finalized tip trees.
fn treestate(&self, hash_or_height: HashOrHeight) -> Option<Treestate>
Sourcepub fn non_finalized_tip_hash(&self) -> Hash
pub fn non_finalized_tip_hash(&self) -> Hash
Returns the block hash of the tip block.
Sourcepub fn non_finalized_root(&self) -> (Hash, Height)
pub fn non_finalized_root(&self) -> (Hash, Height)
Returns the non-finalized root block hash and height.
Sourcepub fn non_finalized_root_hash(&self) -> Hash
pub fn non_finalized_root_hash(&self) -> Hash
Returns the block hash of the non-finalized root block.
Sourcepub fn non_finalized_nth_hash(&self, n: usize) -> Option<Hash>
pub fn non_finalized_nth_hash(&self, n: usize) -> Option<Hash>
Returns the block hash of the nth block from the non-finalized root.
This is the block at non_finalized_root_height() + n.
Sourcepub(crate) fn rebind_tip(
&mut self,
block: ContextuallyVerifiedBlock,
) -> Result<Arc<ContextuallyVerifiedBlock>, ValidateContextError>
pub(crate) fn rebind_tip( &mut self, block: ContextuallyVerifiedBlock, ) -> Result<Arc<ContextuallyVerifiedBlock>, ValidateContextError>
Replaces the tip block with block, which has the same transactions and the same header
apart from the nonce and Equihash solution, like a solved block proposal.
Only the block hash index, the tip’s history tree, the recorded block size and the stored block depend on those header fields, so this costs a history tree append rather than a block push. An error leaves the chain unchanged.
Returns the replaced tip block, so the caller chooses when to free what only that block holds.
§Panics
If Self::can_rebind_tip() is false, or block is not at the tip height with the
tip’s transactions.
Sourcepub(crate) fn can_rebind_tip(&self) -> bool
pub(crate) fn can_rebind_tip(&self) -> bool
Returns true if the tip block can be rebound: the chain holds the history tree of the
tip’s parent, which finalizing the parent removes.
Sourcefn parent_history_tree(&self) -> Option<Arc<HistoryTree>>
fn parent_history_tree(&self) -> Option<Arc<HistoryTree>>
Returns the history tree of the tip block’s parent, if the chain still holds it.
Sourcepub fn non_finalized_tip_height(&self) -> Height
pub fn non_finalized_tip_height(&self) -> Height
Return the non-finalized tip height for this chain.
§Panics
Panics if called while the chain is empty, or while the chain is updating its internal state with the first block.
Sourcefn max_block_height(&self) -> Option<Height>
fn max_block_height(&self) -> Option<Height>
Return the non-finalized tip height for this chain,
or None if self.blocks is empty.
Sourcepub fn tip_block(&self) -> Option<&ContextuallyVerifiedBlock>
pub fn tip_block(&self) -> Option<&ContextuallyVerifiedBlock>
Return the non-finalized tip block for this chain,
or None if self.blocks is empty.
Sourcepub(crate) fn index_entry_count(&self) -> usize
pub(crate) fn index_entry_count(&self) -> usize
Returns the number of blocks, transactions, transparent outputs and spends, and nullifiers in this chain.
Sourcepub(crate) fn block_index_entry_count(
&self,
block: &ContextuallyVerifiedBlock,
) -> usize
pub(crate) fn block_index_entry_count( &self, block: &ContextuallyVerifiedBlock, ) -> usize
Returns the index entries that block adds to this chain, counting the block itself.
Chains that contain the same block share these entries.
Sourcepub(crate) fn detach_index_entries_at(&mut self, height: Height)
pub(crate) fn detach_index_entries_at(&mut self, height: Height)
Records that this chain is about to remove the transaction, spend, and nullifier entries
of the block at height separately from other chains.
Sourcepub(crate) fn detached_index_entry_count(&self) -> usize
pub(crate) fn detached_index_entry_count(&self) -> usize
Returns an estimate of the transaction, spend, and nullifier entries this chain doesn’t share with other chains.
A chain can’t hold more unshared entries than it has.
Sourcefn common_tip_height(&self, other: &Chain) -> Option<Height>
fn common_tip_height(&self, other: &Chain) -> Option<Height>
Returns the height of the highest block that this chain and other share, if they share
their root block.
Sourcefn index_entries_above(&self, height: Height) -> usize
fn index_entries_above(&self, height: Height) -> usize
Returns the transaction, spend, and nullifier entries in the blocks above height.
Sourcepub(crate) fn divergent_index_entries(&self, other: &Chain) -> Option<usize>
pub(crate) fn divergent_index_entries(&self, other: &Chain) -> Option<usize>
Returns the transaction, spend, and nullifier entries in the blocks that this chain and
other don’t share, or None if they don’t share their root block.
Rebuilds this chain’s transaction, spend, and nullifier maps from other’s, so they share
the entries of the blocks the chains have in common.
The maps keep the same contents. Does nothing if the chains don’t share their root block.
Returns the number of entries in the transaction, spend, and nullifier indexes.
Sourcepub(crate) fn created_ordered_utxo(
&self,
outpoint: &OutPoint,
) -> Option<&Arc<OrderedUtxo>>
pub(crate) fn created_ordered_utxo( &self, outpoint: &OutPoint, ) -> Option<&Arc<OrderedUtxo>>
Returns the output created by this chain at outpoint, including outputs that this chain
already spends.
Outputs stay in the block that created them, which every chain containing the block shares, so the chain doesn’t keep its own copy of each output.
Sourcepub fn created_utxo(&self, outpoint: &OutPoint) -> Option<Utxo>
pub fn created_utxo(&self, outpoint: &OutPoint) -> Option<Utxo>
Returns the transparent::Utxo pointed to by the given
transparent::OutPoint if it was created by this chain.
UTXOs are returned regardless of whether they have been spent.
Sourcepub fn spending_transaction_hash(&self, spend: &Spend) -> Option<Hash>
pub fn spending_transaction_hash(&self, spend: &Spend) -> Option<Hash>
Returns the Hash of the transaction that spent an output at
the provided transparent::OutPoint or revealed the provided nullifier, if it exists
and is spent or revealed by this chain.
Sourcefn transparent_transfers<'a>(
&'a self,
addresses: &'a HashSet<Address>,
heights: impl RangeBounds<Height>,
) -> impl Iterator<Item = &'a AddressBlockTransfers> + 'a
fn transparent_transfers<'a>( &'a self, addresses: &'a HashSet<Address>, heights: impl RangeBounds<Height>, ) -> impl Iterator<Item = &'a AddressBlockTransfers> + 'a
Returns the transparent transfers of addresses in the blocks of this chain at
heights, in chain order.
Sourcepub fn partial_transparent_balance_change(
&self,
addresses: &HashSet<Address>,
) -> (Amount<NegativeAllowed>, u64)
pub fn partial_transparent_balance_change( &self, addresses: &HashSet<Address>, ) -> (Amount<NegativeAllowed>, u64)
Returns a tuple of the transparent balance change and the total received funds for
addresses in this non-finalized chain.
If the balance doesn’t change for any of the addresses, returns zero.
§Correctness
Callers should apply this balance change to the finalized state balance for addresses.
The total balance will only be correct if this partial chain matches the finalized state. Specifically, the root of this partial chain must be a child block of the finalized tip.
Sourcepub(crate) fn partial_transparent_balance_change_from(
&self,
addresses: &HashSet<Address>,
min_height: Height,
) -> (Amount<NegativeAllowed>, u64)
pub(crate) fn partial_transparent_balance_change_from( &self, addresses: &HashSet<Address>, min_height: Height, ) -> (Amount<NegativeAllowed>, u64)
Returns the transparent balance change and the total received funds for addresses in
the blocks of this chain at min_height and above.
Readers use this when the finalized state already contains the blocks below min_height,
so they are counted once.
Sourcepub fn partial_transparent_utxo_changes(
&self,
addresses: &HashSet<Address>,
query_height_range: &RangeInclusive<Height>,
max_entries: Option<usize>,
) -> (BTreeMap<OutputLocation, Output>, BTreeSet<OutputLocation>)
pub fn partial_transparent_utxo_changes( &self, addresses: &HashSet<Address>, query_height_range: &RangeInclusive<Height>, max_entries: Option<usize>, ) -> (BTreeMap<OutputLocation, Output>, BTreeSet<OutputLocation>)
Returns the transparent UTXO changes for addresses in this non-finalized chain:
- the UTXOs created by this chain in
query_height_rangethat it doesn’t spend, at mostmax_entriesof them, the first in chain order, and - the outputs this chain spends.
If the UTXOs don’t change for any of the addresses, returns empty lists.
§Correctness
Callers should apply these non-finalized UTXO changes to the finalized state UTXOs.
The UTXOs will only be correct if the non-finalized chain matches or overlaps with the finalized state.
Specifically, a block in the partial chain must be a child block of the finalized tip. (But the child block does not have to be the partial chain root.)
Combining these UTXOs with finalized UTXOs, removing the spent outputs, and keeping the
first max_entries gives the same result as using all the created UTXOs: the unspent
UTXOs this method leaves out are all after the ones it returns.
Sourcepub fn partial_transparent_spent_utxo_count(
&self,
addresses: &HashSet<Address>,
) -> usize
pub fn partial_transparent_spent_utxo_count( &self, addresses: &HashSet<Address>, ) -> usize
Returns the number of UTXOs that addresses spend in this partial non-finalized chain.
A limited finalized UTXO query has to over-fetch by this many entries, because any of the UTXOs it returns can turn out to be spent here.
Sourcepub fn partial_transparent_tx_ids(
&self,
addresses: &HashSet<Address>,
query_height_range: RangeInclusive<Height>,
max_entries: Option<usize>,
) -> BTreeMap<TransactionLocation, Hash>
pub fn partial_transparent_tx_ids( &self, addresses: &HashSet<Address>, query_height_range: RangeInclusive<Height>, max_entries: Option<usize>, ) -> BTreeMap<TransactionLocation, Hash>
Returns the transaction::Hashes used by addresses to receive or spend funds,
in the non-finalized chain, filtered using the query_height_range,
at most max_entries of them, the first in chain order.
If none of the addresses receive or spend funds in this partial chain, returns an empty list.
§Correctness
Callers should combine these non-finalized transactions with the finalized state transactions.
The transaction IDs will only be correct if the non-finalized chain matches or overlaps with the finalized state.
Specifically, a block in the partial chain must be a child block of the finalized tip. (But the child block does not have to be the partial chain root.)
This condition does not apply if there is only one address. Since address transactions are only appended by blocks, and the finalized state query reads them in order, it is impossible to get inconsistent transactions for a single address.
Sourcepub(crate) fn note_commitment_trees_for_tip(&self) -> NoteCommitmentTrees
pub(crate) fn note_commitment_trees_for_tip(&self) -> NoteCommitmentTrees
Returns the tip’s note commitment trees and subtrees, which a new block’s trees extend.
Sourcefn update_chain_tip_with_block_parallel(
&mut self,
contextually_valid: &ContextuallyVerifiedBlock,
precomputed: Option<&PrecomputedTrees>,
) -> Result<(), ValidateContextError>
fn update_chain_tip_with_block_parallel( &mut self, contextually_valid: &ContextuallyVerifiedBlock, precomputed: Option<&PrecomputedTrees>, ) -> Result<(), ValidateContextError>
Update the chain tip with the contextually_valid block,
running note commitment tree updates in parallel with other updates.
Used to implement update_chain_tip_with::<ContextuallyVerifiedBlock>.
Sourcefn update_chain_tip_with_block_except_trees(
&mut self,
contextually_valid: &ContextuallyVerifiedBlock,
) -> Result<(), ValidateContextError>
fn update_chain_tip_with_block_except_trees( &mut self, contextually_valid: &ContextuallyVerifiedBlock, ) -> Result<(), ValidateContextError>
Update the chain tip with the contextually_valid block,
except for the note commitment and history tree updates.
Used to implement update_chain_tip_with::<ContextuallyVerifiedBlock>.
Source§impl Chain
impl Chain
Sourcefn add_spent_outpoints(
&mut self,
transaction: &Transaction,
spending_tx_hash: &Hash,
)
fn add_spent_outpoints( &mut self, transaction: &Transaction, spending_tx_hash: &Hash, )
Indexes the outpoints that transaction, with hash spending_tx_hash, spends.
Sourcefn remove_spent_outpoints(&mut self, transaction: &Transaction)
fn remove_spent_outpoints(&mut self, transaction: &Transaction)
Removes the outpoints that transaction spends from the index.
Trait Implementations§
impl Eq for Chain
Source§impl Ord for Chain
impl Ord for Chain
Source§fn cmp(&self, other: &Self) -> Ordering
fn cmp(&self, other: &Self) -> Ordering
Chain order for the NonFinalizedState’s chain_set.
Chains with higher cumulative Proof of Work are Ordering::Greater.
Ties are broken by preferring the chain whose tip block was received
first (the earlier received_time stamp set by the block verifier),
implementing the consensus rule
quoted below. Sibling blocks on Zcash always have equal work (nBits
is fully determined by their ancestors), so without first-received
preference, an already-adopted tip could be displaced by an equal-work
sibling arriving arbitrarily later.
The tip block hash remains as a final tie-breaker when receipt times
are equal, so that the order is total. Chains whose tip has no receipt
stamp (checkpoint sync, backup restore) compare as if received before
any stamped block, like zcashd’s disk-loaded blocks, which all share
nSequenceId 0.
“At a given point in time, each full validator is aware of a set of candidate blocks. These form a tree rooted at the genesis block, where each node in the tree refers to its parent via the hashPrevBlock block header field.
A path from the root toward the leaves of the tree consisting of a sequence of one or more valid blocks consistent with consensus rules, is called a valid block chain.
In order to choose the best valid block chain in its view of the overall block tree, a node sums the work … of all blocks in each valid block chain, and considers the valid block chain with greatest total work to be best.
To break ties between leaf blocks, a node will prefer the block that it received first.
The consensus protocol is designed to ensure that for any given block height, the vast majority of nodes should eventually agree on their best valid block chain up to that height.“
https://zips.z.cash/protocol/protocol.pdf#blockchain
§Correctness
Chain::cmp is used in a BTreeSet, so the fields accessed by cmp must not have
interior mutability. The tip block’s received_time is set by the block verifier
before the block is pushed onto a chain, and is never modified afterwards.
cmp returns Ordering::Equal only when both the cumulative work and
the tip hash match. Two chains with the same tip hash share the stored tip
block (and therefore its receipt time), so they always compare equal. The
NonFinalizedState::chain_set is a BTreeSet<Arc<Chain>>, so an
attempt to insert a chain that compares equal to an existing entry is a
no-op rather than a process-fatal panic. Callers that need to replace
such a chain must remove the existing entry first.
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
1.21.0 (const: unstable) · Source§fn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialEq for Chain
impl PartialEq for Chain
Source§fn eq(&self, other: &Self) -> bool
fn eq(&self, other: &Self) -> bool
Chain equality for NonFinalizedState::chain_set, using proof of
work, then the tip block’s receipt time, then the tip block hash.
Two chains with the same cumulative work and tip hash are equal; the
chain_set uses this to keep tip hashes unique.
Source§impl PartialOrd for Chain
impl PartialOrd for Chain
Source§impl UpdateWith<(ValueBalance<NegativeAllowed>, Height, usize)> for Chain
impl UpdateWith<(ValueBalance<NegativeAllowed>, Height, usize)> for Chain
Source§fn revert_chain_with(
&mut self,
(block_value_pool_change, height, _size): &(ValueBalance<NegativeAllowed>, Height, usize),
position: RevertPosition,
)
fn revert_chain_with( &mut self, (block_value_pool_change, height, _size): &(ValueBalance<NegativeAllowed>, Height, usize), position: RevertPosition, )
Revert the chain state using a block chain value pool change.
When forking from the tip, subtract the block’s chain value pool change.
When finalizing the root, leave the chain value pool balances unchanged.
ChainInner::chain_value_pools tracks the chain value pools for all finalized blocks, and
the non-finalized blocks in this chain. So finalizing the root doesn’t change the set of
blocks it tracks.
§Panics
Panics if the chain pool value balance is invalid after we subtract the block value pool change.
Source§fn update_chain_tip_with(
&mut self,
(block_value_pool_change, height, size): &(ValueBalance<NegativeAllowed>, Height, usize),
) -> Result<(), ValidateContextError>
fn update_chain_tip_with( &mut self, (block_value_pool_change, height, size): &(ValueBalance<NegativeAllowed>, Height, usize), ) -> Result<(), ValidateContextError>
T is added to the chain tip,
update Chain cumulative data members to add data that are derived from T.Source§impl UpdateWith<ContextuallyVerifiedBlock> for Chain
impl UpdateWith<ContextuallyVerifiedBlock> for Chain
Source§fn update_chain_tip_with(
&mut self,
contextually_valid: &ContextuallyVerifiedBlock,
) -> Result<(), ValidateContextError>
fn update_chain_tip_with( &mut self, contextually_valid: &ContextuallyVerifiedBlock, ) -> Result<(), ValidateContextError>
T is added to the chain tip,
update Chain cumulative data members to add data that are derived from T.Source§fn revert_chain_with(
&mut self,
contextually_valid: &ContextuallyVerifiedBlock,
position: RevertPosition,
)
fn revert_chain_with( &mut self, contextually_valid: &ContextuallyVerifiedBlock, position: RevertPosition, )
T is removed from position in the chain,
revert Chain cumulative data members to remove data that are derived from T.Auto Trait Implementations§
impl Freeze for Chain
impl RefUnwindSafe for Chain
impl Send for Chain
impl Sync for Chain
impl Unpin for Chain
impl UnsafeUnpin for Chain
impl UnwindSafe for Chain
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
§impl<T> Conv for T
impl<T> Conv for T
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.impl<T> ErasedDestructor for Twhere
T: 'static,
§impl<T> FmtForward for T
impl<T> FmtForward for T
§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self to use its Binary implementation when Debug-formatted.§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self to use its Display implementation when
Debug-formatted.§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self to use its LowerExp implementation when
Debug-formatted.§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self to use its LowerHex implementation when
Debug-formatted.§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self to use its Octal implementation when Debug-formatted.§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self to use its Pointer implementation when
Debug-formatted.§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self to use its UpperExp implementation when
Debug-formatted.§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self to use its UpperHex implementation when
Debug-formatted.§fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreimpl<T> MaybeSendSync for T
§impl<D> OwoColorize for D
impl<D> OwoColorize for D
§fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
§fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
§fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>
fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>
§fn default_color(&self) -> FgColorDisplay<'_, Default, Self>
fn default_color(&self) -> FgColorDisplay<'_, Default, Self>
§fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>
fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>
§fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>
fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>
§fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>
fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>
§fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>
fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>
§fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>
fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>
§fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>
fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>
§fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>
fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>
§fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>
fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>
§fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>
fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>
§fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>
fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>
§fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>
fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>
§fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
§fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
§fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
§fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
§fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>
fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>
§fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>
fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>
§fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>
fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>
§fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>
fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>
§fn blink_fast(&self) -> BlinkFastDisplay<'_, Self>
fn blink_fast(&self) -> BlinkFastDisplay<'_, Self>
§fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>
fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>
§fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
OwoColorize::fg] or
a color-specific method, such as [OwoColorize::green], Read more§fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
OwoColorize::bg] or
a color-specific method, such as [OwoColorize::on_yellow], Read more§fn fg_rgb<const R: u8, const G: u8, const B: u8>(
&self,
) -> FgColorDisplay<'_, CustomColor<R, G, B>, Self>
fn fg_rgb<const R: u8, const G: u8, const B: u8>( &self, ) -> FgColorDisplay<'_, CustomColor<R, G, B>, Self>
§fn bg_rgb<const R: u8, const G: u8, const B: u8>(
&self,
) -> BgColorDisplay<'_, CustomColor<R, G, B>, Self>
fn bg_rgb<const R: u8, const G: u8, const B: u8>( &self, ) -> BgColorDisplay<'_, CustomColor<R, G, B>, Self>
§fn truecolor(&self, r: u8, g: u8, b: u8) -> FgDynColorDisplay<'_, Rgb, Self>
fn truecolor(&self, r: u8, g: u8, b: u8) -> FgDynColorDisplay<'_, Rgb, Self>
§fn on_truecolor(&self, r: u8, g: u8, b: u8) -> BgDynColorDisplay<'_, Rgb, Self>
fn on_truecolor(&self, r: u8, g: u8, b: u8) -> BgDynColorDisplay<'_, Rgb, Self>
§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read more§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read more§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self, then passes self.as_ref() into the pipe function.§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self, then passes self.as_mut() into the pipe
function.§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self, then passes self.deref() into the pipe function.§impl<T> Pointable for T
impl<T> Pointable for T
§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<Response, Error> ResponseResult<Response, Error> for Response
impl<Response, Error> ResponseResult<Response, Error> for Response
Source§fn into_result(self) -> Result<Response, Error>
fn into_result(self) -> Result<Response, Error>
Result that can be sent as a response.§impl<T> Tap for T
impl<T> Tap for T
§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B> of a value. Read more§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B> of a value. Read more§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R> view of a value. Read more§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R> view of a value. Read more§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target of a value. Read more§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target of a value. Read more§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap() only in debug builds, and is erased in release builds.§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut() only in debug builds, and is erased in release
builds.§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow() only in debug builds, and is erased in release
builds.§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut() only in debug builds, and is erased in release
builds.§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref() only in debug builds, and is erased in release
builds.§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut() only in debug builds, and is erased in release
builds.§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref() only in debug builds, and is erased in release
builds.§impl<T> TryConv for T
impl<T> TryConv for T
§impl<T> WithSubscriber for T
impl<T> WithSubscriber for T
§fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘwhere
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘwhere
S: Into<Dispatch>,
§fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ
fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ
Source§impl<T> WithSubscriber for T
impl<T> WithSubscriber for T
Source§fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘwhere
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘwhere
S: Into<Dispatch>,
Source§fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ
fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ
Layout§
Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...) attributes. Please see the Rust Reference's “Type Layout” chapter for details on type layout guarantees.
Size: 1040 bytes