pub struct Storage {
verified: VerifiedSet,
tip_rejected_exact: HashMap<UnminedTxId, ExactTipRejectionError>,
tip_rejected_same_effects: HashMap<Hash, SameEffectsTipRejectionError>,
chain_rejected_same_effects: HashMap<SameEffectsChainRejectionError, EvictionList>,
eviction_memory_time: Duration,
tx_cost_limit: u64,
}
Expand description

Hold mempool verified and rejected mempool transactions.

## Fields

verified: VerifiedSet

The set of verified transactions in the mempool.

tip_rejected_exact: HashMap<UnminedTxId, ExactTipRejectionError>

The set of transactions rejected due to bad authorizations, or for other reasons, and their rejection reasons. These rejections only apply to the current tip.

Only transactions with the exact UnminedTxId are invalid.

tip_rejected_same_effects: HashMap<Hash, SameEffectsTipRejectionError>

A set of transactions rejected for their effects, and their rejection reasons. These rejections only apply to the current tip.

Any transaction with the same transaction::Hash is invalid.

chain_rejected_same_effects: HashMap<SameEffectsChainRejectionError, EvictionList>

Sets of transactions rejected for their effects, keyed by rejection reason. These rejections apply until a rollback or network upgrade.

Any transaction with the same transaction::Hash is invalid.

An EvictionList is used for both randomly evicted and expired transactions, even if it is only needed for the evicted ones. This was done just to simplify the existing code; there is no harm in having a timeout for expired transactions too since re-checking expired transactions is cheap.

eviction_memory_time: Duration

The mempool transaction eviction age limit. Same as config::Config::eviction_memory_time.

tx_cost_limit: u64

Max total cost of the verified mempool set, beyond which transactions are evicted to make room.

## Implementations

Insert a VerifiedUnminedTx into the mempool, caching any rejections.

Returns an error if the mempool’s verified transactions or rejection caches prevent this transaction from being inserted. These errors should not be propagated to peers, because the transactions are valid.

If inserting this transaction evicts other transactions, they will be tracked as SameEffectsChainRejectionError::RandomlyEvicted.

Remove transactions from the mempool via exact UnminedTxId.

For v5 transactions, transactions are matched by WTXID, using both the:

• non-malleable transaction ID, and
• authorizing data hash.

This matches the exact transaction, with identical blockchain effects, signatures, and proofs.

Returns the number of transactions which were removed.

Removes from the ‘verified’ set, if present. Maintains the order in which the other unmined transactions have been inserted into the mempool.

Does not add or remove from the ‘rejected’ tracking set.

Remove transactions from the mempool via non-malleable transaction::Hash.

For v5 transactions, transactions are matched by TXID, using only the non-malleable transaction ID. This matches any transaction with the same effect on the blockchain state, even if its signatures and proofs are different.

Returns the number of transactions which were removed.

Removes from the ‘verified’ set, if present. Maintains the order in which the other unmined transactions have been inserted into the mempool.

Does not add or remove from the ‘rejected’ tracking set.

Clears the whole mempool storage.

Clears rejections that only apply to the current tip.

Clears rejections that only apply to the current tip.

##### Security

This method must be called at the end of every method that adds rejections. Otherwise, peers could make our reject lists use a lot of RAM.

Returns the set of UnminedTxIds in the mempool.

Returns the set of UnminedTxs in the mempool.

Returns the number of transactions in the mempool.

Returns the set of UnminedTxes with exactly matching tx_ids in the mempool.

This matches the exact transaction, with identical blockchain effects, signatures, and proofs.

Returns the set of UnminedTxes with matching transaction::Hashes in the mempool.

This matches transactions with the same effects, regardless of [AuthDigest].

Returns true if a transaction exactly matching an UnminedTxId is in the mempool.

This matches the exact transaction, with identical blockchain effects, signatures, and proofs.

Returns the number of rejected UnminedTxIds or transaction::Hashes.

Transactions on multiple rejected lists are counted multiple times.

Add a transaction to the rejected list for the given reason.

Returns the rejection error if a transaction matching an UnminedTxId is in any mempool rejected list.

This matches transactions based on each rejection list’s matching rule.

Returns an arbitrary error if the transaction is in multiple lists.

Returns the set of UnminedTxIds matching tx_ids in the rejected list.

This matches transactions based on each rejection list’s matching rule.

Returns true if a transaction matching the supplied UnminedTxId is in the mempool rejected list.

This matches transactions based on each rejection list’s matching rule.

Add a transaction that failed download and verification to the rejected list if needed, depending on the reason for the failure.

Remove transactions from the mempool if they have not been mined after a specified height, per ZIP-203.

Transactions will have a new field, nExpiryHeight, which will set the block height after which transactions will be removed from the mempool if they have not been mined.

If it is already in the mempool (or in its rejected list) then it shouldn’t be downloaded/verified.

Update metrics related to the rejected lists.

Must be called every time the rejected lists change.

## Trait Implementations

Executes the destructor for this type. Read more

## Blanket Implementations

Gets the TypeId of self. Read more

Borrow this concrete type as a &dyn Any

Borrow this concrete type as a &mut dyn Any

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. Read more

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. Read more

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

Formats each item in a sequence. Read more

Returns the argument unchanged.

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

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

Calls U::from(self).

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

Set the foreground color generically Read more

Set the background color generically. Read more

Change the foreground color to black

Change the foreground color to black

Change the foreground color to red

Change the foreground color to red

Change the foreground color to green

Change the foreground color to green

Change the foreground color to yellow

Change the foreground color to yellow

Change the foreground color to blue

Change the foreground color to blue

Change the foreground color to magenta

Change the foreground color to magenta

Change the foreground color to purple

Change the foreground color to purple

Change the foreground color to cyan

Change the foreground color to cyan

Change the foreground color to white

Change the foreground color to white

Change the foreground color to bright black

Change the foreground color to bright black

Change the foreground color to bright red

Change the foreground color to bright red

Change the foreground color to bright green

Change the foreground color to bright green

Change the foreground color to bright yellow

Change the foreground color to bright yellow

Change the foreground color to bright blue

Change the foreground color to bright blue

Change the foreground color to bright magenta

Change the foreground color to bright magenta

Change the foreground color to bright purple

Change the foreground color to bright purple

Change the foreground color to bright cyan

Change the foreground color to bright cyan

Change the foreground color to bright white

Change the foreground color to bright white

Make the text bold

Make the text dim

Make the text italicized

Make the text italicized

Make the text blink (but fast!)

Swap the foreground and background colors

Hide the text

Cross out the text

Set the foreground color at runtime. Only use if you do not know which color will be used at compile-time. If the color is constant, use either OwoColorize::fg or a color-specific method, such as OwoColorize::green, Read more

Set the background color at runtime. Only use if you do not know what color to use at compile-time. If the color is constant, use either OwoColorize::bg or a color-specific method, such as OwoColorize::on_yellow, Read more

Sets the foreground color to an RGB value.

Sets the background color to an RGB value.

Apply a runtime-determined style

Set the foreground color generically Read more

Set the background color generically. Read more

Change the foreground color to black

Change the background color to black

Change the foreground color to red

Change the background color to red

Change the foreground color to green

Change the background color to green

Change the foreground color to yellow

Change the background color to yellow

Change the foreground color to blue

Change the background color to blue

Change the foreground color to magenta

Change the background color to magenta

Change the foreground color to purple

Change the background color to purple

Change the foreground color to cyan

Change the background color to cyan

Change the foreground color to white

Change the background color to white

Change the foreground color to the terminal default

Change the background color to the terminal default

Change the foreground color to bright black

Change the background color to bright black

Change the foreground color to bright red

Change the background color to bright red

Change the foreground color to bright green

Change the background color to bright green

Change the foreground color to bright yellow

Change the background color to bright yellow

Change the foreground color to bright blue

Change the background color to bright blue

Change the foreground color to bright magenta

Change the background color to bright magenta

Change the foreground color to bright purple

Change the background color to bright purple

Change the foreground color to bright cyan

Change the background color to bright cyan

Change the foreground color to bright white

Change the background color to bright white

Make the text bold

Make the text dim

Make the text italicized

Make the text italicized

Make the text blink (but fast!)

Swap the foreground and background colors

Hide the text

Cross out the text

Set the foreground color at runtime. Only use if you do not know which color will be used at compile-time. If the color is constant, use either OwoColorize::fg or a color-specific method, such as OwoColorize::green, Read more

Set the background color at runtime. Only use if you do not know what color to use at compile-time. If the color is constant, use either OwoColorize::bg or a color-specific method, such as OwoColorize::on_yellow, Read more

Set the foreground color to a specific RGB value.

Set the background color to a specific RGB value.

Sets the foreground color to an RGB value.

Sets the background color to an RGB value.

Apply a runtime-determined style

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

Converts the type into a Result that can be sent as a response.

Should always be Self

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.

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more