Struct snarkos_consensus::memory_pool::MemoryPool[][src]

pub struct MemoryPool<T: Transaction> {
    pub transactions: HashMap<Vec<u8>, Entry<T>>,
    pub total_size_in_bytes: usize,
}

Stores transactions received by the server. Transaction entries will eventually be fetched by the miner and assembled into blocks.

Fields

transactions: HashMap<Vec<u8>, Entry<T>>

The mapping of all unconfirmed transaction IDs to their corresponding transaction data.

total_size_in_bytes: usize

The total size in bytes of the current memory pool.

Implementations

impl<T: Transaction> MemoryPool<T>[src]

pub fn new() -> Self[src]

Initialize a new memory pool with no transactions

pub fn from_storage<P: LoadableMerkleParameters>(
    storage: &Ledger<T, P>
) -> Result<Self, ConsensusError>
[src]

Load the memory pool from previously stored state in storage

pub fn store<P: LoadableMerkleParameters>(
    &self,
    storage: &Ledger<T, P>
) -> Result<(), ConsensusError>
[src]

Store the memory pool state to the database

pub fn insert<P: LoadableMerkleParameters>(
    &mut self,
    storage: &Ledger<T, P>,
    entry: Entry<T>
) -> Result<Option<Vec<u8>>, ConsensusError>
[src]

Adds entry to memory pool if valid in the current ledger.

pub fn cleanse<P: LoadableMerkleParameters>(
    &mut self,
    storage: &Ledger<T, P>
) -> Result<(), ConsensusError>
[src]

Cleanse the memory pool of outdated transactions.

pub fn remove(
    &mut self,
    entry: &Entry<T>
) -> Result<Option<Vec<u8>>, ConsensusError>
[src]

Removes transaction from memory pool or error.

pub fn remove_by_hash(
    &mut self,
    transaction_id: &[u8]
) -> Result<Option<Entry<T>>, ConsensusError>
[src]

Removes transaction from memory pool based on the transaction id.

pub fn contains(&self, entry: &Entry<T>) -> bool[src]

Returns whether or not the memory pool contains the entry.

pub fn get_candidates<P: LoadableMerkleParameters>(
    &self,
    storage: &Ledger<T, P>,
    max_size: usize
) -> Result<DPCTransactions<T>, ConsensusError>
[src]

Get candidate transactions for a new block.

Trait Implementations

impl<T: Clone + Transaction> Clone for MemoryPool<T>[src]

impl<T: Debug + Transaction> Debug for MemoryPool<T>[src]

impl<T: Transaction> Default for MemoryPool<T>[src]

Auto Trait Implementations

impl<T> RefUnwindSafe for MemoryPool<T> where
    T: RefUnwindSafe

impl<T> Send for MemoryPool<T> where
    T: Send

impl<T> Sync for MemoryPool<T> where
    T: Sync

impl<T> Unpin for MemoryPool<T> where
    T: Unpin

impl<T> UnwindSafe for MemoryPool<T> where
    T: UnwindSafe

Blanket Implementations

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

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

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

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

impl<T> Instrument for T[src]

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

impl<T> Pointable for T

type Init = T

The type for initializers.

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

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<V, T> VZip<V> for T where
    V: MultiLane<T>,