Struct snarkos_node_consensus::Consensus
source · pub struct Consensus<N: Network, C: ConsensusStorage<N>> { /* private fields */ }Implementations§
source§impl<N: Network, C: ConsensusStorage<N>> Consensus<N, C>
impl<N: Network, C: ConsensusStorage<N>> Consensus<N, C>
sourcepub fn new(ledger: Ledger<N, C>, is_dev: bool) -> Result<Self>
pub fn new(ledger: Ledger<N, C>, is_dev: bool) -> Result<Self>
Initializes a new instance of consensus.
sourcepub const fn coinbase_puzzle(&self) -> &CoinbasePuzzle<N>
pub const fn coinbase_puzzle(&self) -> &CoinbasePuzzle<N>
Returns the coinbase puzzle.
sourcepub const fn memory_pool(&self) -> &MemoryPool<N>
pub const fn memory_pool(&self) -> &MemoryPool<N>
Returns the memory pool.
sourcepub fn check_transaction_basic(
&self,
transaction: &Transaction<N>,
rejected_id: Option<Field<N>>
) -> Result<()>
pub fn check_transaction_basic( &self, transaction: &Transaction<N>, rejected_id: Option<Field<N>> ) -> Result<()>
Checks the given transaction is well-formed and unique.
sourcepub fn check_next_block(&self, block: &Block<N>) -> Result<()>
pub fn check_next_block(&self, block: &Block<N>) -> Result<()>
Checks the given block is valid next block.
sourcepub fn add_unconfirmed_transaction(
&self,
transaction: Transaction<N>
) -> Result<()>
pub fn add_unconfirmed_transaction( &self, transaction: Transaction<N> ) -> Result<()>
Adds the given unconfirmed transaction to the memory pool.
sourcepub fn add_unconfirmed_solution(
&self,
solution: &ProverSolution<N>
) -> Result<()>
pub fn add_unconfirmed_solution( &self, solution: &ProverSolution<N> ) -> Result<()>
Adds the given unconfirmed solution to the memory pool.
sourcepub fn is_coinbase_target_met(&self) -> Result<bool>
pub fn is_coinbase_target_met(&self) -> Result<bool>
Returns true if the coinbase target is met.
sourcepub fn propose_next_block<R: Rng + CryptoRng>(
&self,
private_key: &PrivateKey<N>,
rng: &mut R
) -> Result<Block<N>>
pub fn propose_next_block<R: Rng + CryptoRng>( &self, private_key: &PrivateKey<N>, rng: &mut R ) -> Result<Block<N>>
Returns a candidate for the next block in the ledger.
sourcepub fn advance_to_next_block(&self, block: &Block<N>) -> Result<()>
pub fn advance_to_next_block(&self, block: &Block<N>) -> Result<()>
Advances the ledger to the next block.
sourcepub fn refresh_memory_pool(&self) -> Result<()>
pub fn refresh_memory_pool(&self) -> Result<()>
Clears the memory pool of invalid solutions and transactions.
sourcepub fn clear_memory_pool(&self) -> Result<()>
pub fn clear_memory_pool(&self) -> Result<()>
Clears the memory pool of all solutions and transactions.
Trait Implementations§
Auto Trait Implementations§
impl<N, C> !RefUnwindSafe for Consensus<N, C>
impl<N, C> Send for Consensus<N, C>
impl<N, C> Sync for Consensus<N, C>
impl<N, C> Unpin for Consensus<N, C>where C: Unpin, N: Unpin, <N as Network>::BlockHash: Unpin, <N as Environment>::Field: Unpin, <<N as Environment>::PairingCurve as PairingEngine>::G1Affine: Unpin, <N as Environment>::Projective: Unpin, <N as Environment>::Scalar: Unpin, <N as Network>::StateRoot: Unpin, <N as Network>::TransactionID: Unpin, <N as Network>::TransitionID: Unpin,
impl<N, C> !UnwindSafe for Consensus<N, C>
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more