Struct snarkos_consensus::consensus::Consensus[][src]

pub struct Consensus<S: Storage> {
    pub parameters: ConsensusParameters,
    pub public_parameters: PublicParameters<Components>,
    pub ledger: Arc<MerkleTreeLedger<S>>,
    pub memory_pool: Mutex<MemoryPool<Tx>>,
}

Fields

parameters: ConsensusParameterspublic_parameters: PublicParameters<Components>ledger: Arc<MerkleTreeLedger<S>>memory_pool: Mutex<MemoryPool<Tx>>

Implementations

impl<S: Storage> Consensus<S>[src]

pub fn verify_transaction(
    &self,
    transaction: &Tx
) -> Result<bool, ConsensusError>
[src]

Check if the transaction is valid.

pub fn verify_transactions(
    &self,
    transactions: &[Tx]
) -> Result<bool, ConsensusError>
[src]

Check if the transactions are valid.

pub fn verify_block(&self, block: &Block<Tx>) -> Result<bool, ConsensusError>[src]

Check if the block is valid. Verify transactions and transaction fees.

pub fn receive_block(&self, block: &Block<Tx>) -> Result<(), ConsensusError>[src]

Receive a block from an external source and process it based on ledger state.

pub fn process_block(&self, block: &Block<Tx>) -> Result<(), ConsensusError>[src]

Return whether or not the given block is valid and insert it.

  1. Verify that the block header is valid.
  2. Verify that the transactions are valid.
  3. Insert/canonize block.

pub fn create_transaction<R: Rng>(
    &self,
    old_records: Vec<DPCRecord<Components>>,
    old_account_private_keys: Vec<AccountPrivateKey<Components>>,
    new_record_owners: Vec<AccountAddress<Components>>,
    new_birth_program_ids: Vec<Vec<u8>>,
    new_death_program_ids: Vec<Vec<u8>>,
    new_is_dummy_flags: Vec<bool>,
    new_values: Vec<u64>,
    new_payloads: Vec<RecordPayload>,
    memo: [u8; 32],
    rng: &mut R
) -> Result<(Vec<DPCRecord<Components>>, Tx), ConsensusError>
[src]

Generate a transaction by spending old records and specifying new record attributes

pub fn create_coinbase_transaction<R: Rng>(
    &self,
    block_num: u32,
    transactions: &DPCTransactions<Tx>,
    program_vk_hash: Vec<u8>,
    new_birth_program_ids: Vec<Vec<u8>>,
    new_death_program_ids: Vec<Vec<u8>>,
    recipient: AccountAddress<Components>,
    rng: &mut R
) -> Result<(Vec<DPCRecord<Components>>, Tx), ConsensusError>
[src]

Generate a coinbase transaction given candidate block transactions

Auto Trait Implementations

impl<S> !RefUnwindSafe for Consensus<S>

impl<S> Send for Consensus<S> where
    S: Send + Sync

impl<S> Sync for Consensus<S> where
    S: Send + Sync

impl<S> Unpin for Consensus<S>

impl<S> !UnwindSafe for Consensus<S>

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, 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>,