[−][src]Struct snarkos_consensus::consensus::ConsensusParameters
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)
The authorized inner SNARK IDs
Implementations
impl ConsensusParameters
[src]
pub fn get_block_difficulty(
&self,
prev_header: &BlockHeader,
block_timestamp: i64
) -> u64
[src]
&self,
prev_header: &BlockHeader,
block_timestamp: i64
) -> u64
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]
&self,
header: &BlockHeader,
parent_header: &BlockHeader,
merkle_root_hash: &MerkleRootHash,
pedersen_merkle_root_hash: &PedersenMerkleRootHash
) -> Result<(), ConsensusError>
Verify all fields in a block header.
- The parent hash points to the tip of the chain.
- Transactions hash to merkle root.
- The timestamp is less than 2 hours into the future.
- The timestamp is greater than parent timestamp.
- The header is greater than or equal to target difficulty.
- 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]
&self,
parameters: &<InstantiatedDPC as DPCScheme<MerkleTreeLedger>>::Parameters,
transaction: &Tx,
ledger: &MerkleTreeLedger
) -> Result<bool, ConsensusError>
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]
&self,
parameters: &<InstantiatedDPC as DPCScheme<MerkleTreeLedger>>::Parameters,
transactions: &Vec<Tx>,
ledger: &MerkleTreeLedger
) -> Result<bool, ConsensusError>
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]
&self,
parameters: &<InstantiatedDPC as DPCScheme<MerkleTreeLedger>>::Parameters,
block: &Block<Tx>,
ledger: &MerkleTreeLedger
) -> Result<bool, ConsensusError>
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]
&self,
parameters: &PublicParameters<Components>,
storage: &MerkleTreeLedger,
memory_pool: &mut MemoryPool<Tx>,
block: &Block<Tx>
) -> Result<(), ConsensusError>
Return whether or not the given block is valid and insert it.
- Verify that the block header is valid.
- Verify that the transactions are valid.
- Insert/canonize block.
pub fn receive_block(
&self,
parameters: &PublicParameters<Components>,
storage: &MerkleTreeLedger,
memory_pool: &mut MemoryPool<Tx>,
block: &Block<Tx>
) -> Result<(), ConsensusError>
[src]
&self,
parameters: &PublicParameters<Components>,
storage: &MerkleTreeLedger,
memory_pool: &mut MemoryPool<Tx>,
block: &Block<Tx>
) -> Result<(), ConsensusError>
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]
&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>
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]
&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>
Generate a transaction by spending old records and specifying new record attributes
Trait Implementations
impl Clone for ConsensusParameters
[src]
fn clone(&self) -> ConsensusParameters
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl Debug for ConsensusParameters
[src]
Auto Trait Implementations
impl RefUnwindSafe for ConsensusParameters
impl Send for ConsensusParameters
impl Sync for ConsensusParameters
impl Unpin for ConsensusParameters
impl UnwindSafe for ConsensusParameters
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> Same<T> for T
type Output = T
Should always be Self
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,