[][src]Struct snarkos_consensus::consensus::ConsensusParameters

pub struct ConsensusParameters {
    pub max_block_size: usize,
    pub max_nonce: u32,
    pub target_block_time: i64,
    pub network: Network,
    pub verifier: PoswMarlin,
    pub authorized_inner_snark_ids: Vec<Vec<u8>>,
}

Parameters for a proof of work blockchain.

Fields

max_block_size: usize

Maximum block size in bytes

max_nonce: u32

Maximum nonce value allowed

target_block_time: i64

The amount of time it should take to find a block

network: Network

Network

verifier: PoswMarlin

The Proof of Succinct Work verifier (read-only mode, no proving key loaded)

authorized_inner_snark_ids: Vec<Vec<u8>>

The authorized inner SNARK IDs

Implementations

impl ConsensusParameters[src]

pub fn get_block_difficulty(
    &self,
    prev_header: &BlockHeader,
    block_timestamp: i64
) -> u64
[src]

Calculate the difficulty for the next block based off how long it took to mine the last one.

pub fn is_genesis(block_header: &BlockHeader) -> bool[src]

pub fn verify_header(
    &self,
    header: &BlockHeader,
    parent_header: &BlockHeader,
    merkle_root_hash: &MerkleRootHash,
    pedersen_merkle_root_hash: &PedersenMerkleRootHash
) -> Result<(), ConsensusError>
[src]

Verify all fields in a block header.

  1. The parent hash points to the tip of the chain.
  2. Transactions hash to merkle root.
  3. The timestamp is less than 2 hours into the future.
  4. The timestamp is greater than parent timestamp.
  5. The header is greater than or equal to target difficulty.
  6. The nonce is within the limit.

pub fn verify_transaction(
    &self,
    parameters: &<InstantiatedDPC as DPCScheme<MerkleTreeLedger>>::Parameters,
    transaction: &Tx,
    ledger: &MerkleTreeLedger
) -> Result<bool, ConsensusError>
[src]

Check if the transaction is valid.

pub fn verify_transactions(
    &self,
    parameters: &<InstantiatedDPC as DPCScheme<MerkleTreeLedger>>::Parameters,
    transactions: &Vec<Tx>,
    ledger: &MerkleTreeLedger
) -> Result<bool, ConsensusError>
[src]

Check if the transactions are valid.

pub fn verify_block(
    &self,
    parameters: &<InstantiatedDPC as DPCScheme<MerkleTreeLedger>>::Parameters,
    block: &Block<Tx>,
    ledger: &MerkleTreeLedger
) -> Result<bool, ConsensusError>
[src]

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

pub fn process_block(
    &self,
    parameters: &PublicParameters<Components>,
    storage: &MerkleTreeLedger,
    memory_pool: &mut MemoryPool<Tx>,
    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 receive_block(
    &self,
    parameters: &PublicParameters<Components>,
    storage: &MerkleTreeLedger,
    memory_pool: &mut MemoryPool<Tx>,
    block: &Block<Tx>
) -> Result<(), ConsensusError>
[src]

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

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

Generate a coinbase transaction given candidate block transactions

pub fn create_transaction<R: Rng>(
    &self,
    parameters: &<InstantiatedDPC as DPCScheme<MerkleTreeLedger>>::Parameters,
    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],
    ledger: &MerkleTreeLedger,
    rng: &mut R
) -> Result<(Vec<DPCRecord<Components>>, Tx), ConsensusError>
[src]

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

Trait Implementations

impl Clone for ConsensusParameters[src]

impl Debug for ConsensusParameters[src]

Auto Trait Implementations

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, U> Into<U> for T where
    U: From<T>, 
[src]

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