Struct snarkos_node_bft::Primary
source · pub struct Primary<N: Network> { /* private fields */ }Implementations§
source§impl<N: Network> Primary<N>
impl<N: Network> Primary<N>
sourcepub fn new(
account: Account<N>,
storage: Storage<N>,
ledger: Arc<dyn LedgerService<N>>,
ip: Option<SocketAddr>,
trusted_validators: &[SocketAddr],
dev: Option<u16>
) -> Result<Self>
pub fn new( account: Account<N>, storage: Storage<N>, ledger: Arc<dyn LedgerService<N>>, ip: Option<SocketAddr>, trusted_validators: &[SocketAddr], dev: Option<u16> ) -> Result<Self>
Initializes a new primary instance.
sourcepub async fn run(
&mut self,
bft_sender: Option<BFTSender<N>>,
primary_sender: PrimarySender<N>,
primary_receiver: PrimaryReceiver<N>
) -> Result<()>
pub async fn run( &mut self, bft_sender: Option<BFTSender<N>>, primary_sender: PrimarySender<N>, primary_receiver: PrimaryReceiver<N> ) -> Result<()>
Run the primary instance.
sourcepub fn current_round(&self) -> u64
pub fn current_round(&self) -> u64
Returns the current round.
sourcepub const fn ledger(&self) -> &Arc<dyn LedgerService<N>>
pub const fn ledger(&self) -> &Arc<dyn LedgerService<N>>
Returns the ledger.
sourcepub fn num_workers(&self) -> u8
pub fn num_workers(&self) -> u8
Returns the number of workers.
sourcepub fn proposed_batch(&self) -> &Arc<ProposedBatch<N>>
pub fn proposed_batch(&self) -> &Arc<ProposedBatch<N>>
Returns the batch proposal of our primary, if one currently exists.
source§impl<N: Network> Primary<N>
impl<N: Network> Primary<N>
sourcepub fn num_unconfirmed_transmissions(&self) -> usize
pub fn num_unconfirmed_transmissions(&self) -> usize
Returns the number of unconfirmed transmissions.
sourcepub fn num_unconfirmed_ratifications(&self) -> usize
pub fn num_unconfirmed_ratifications(&self) -> usize
Returns the number of unconfirmed ratifications.
sourcepub fn num_unconfirmed_solutions(&self) -> usize
pub fn num_unconfirmed_solutions(&self) -> usize
Returns the number of solutions.
sourcepub fn num_unconfirmed_transactions(&self) -> usize
pub fn num_unconfirmed_transactions(&self) -> usize
Returns the number of unconfirmed transactions.
source§impl<N: Network> Primary<N>
impl<N: Network> Primary<N>
sourcepub fn unconfirmed_transmission_ids(
&self
) -> impl '_ + Iterator<Item = TransmissionID<N>>
pub fn unconfirmed_transmission_ids( &self ) -> impl '_ + Iterator<Item = TransmissionID<N>>
Returns the unconfirmed transmission IDs.
sourcepub fn unconfirmed_transmissions(
&self
) -> impl '_ + Iterator<Item = (TransmissionID<N>, Transmission<N>)>
pub fn unconfirmed_transmissions( &self ) -> impl '_ + Iterator<Item = (TransmissionID<N>, Transmission<N>)>
Returns the unconfirmed transmissions.
sourcepub fn unconfirmed_solutions(
&self
) -> impl '_ + Iterator<Item = (PuzzleCommitment<N>, Data<ProverSolution<N>>)>
pub fn unconfirmed_solutions( &self ) -> impl '_ + Iterator<Item = (PuzzleCommitment<N>, Data<ProverSolution<N>>)>
Returns the unconfirmed solutions.
sourcepub fn unconfirmed_transactions(
&self
) -> impl '_ + Iterator<Item = (N::TransactionID, Data<Transaction<N>>)>
pub fn unconfirmed_transactions( &self ) -> impl '_ + Iterator<Item = (N::TransactionID, Data<Transaction<N>>)>
Returns the unconfirmed transactions.
source§impl<N: Network> Primary<N>
impl<N: Network> Primary<N>
sourcepub async fn propose_batch(&self) -> Result<()>
pub async fn propose_batch(&self) -> Result<()>
Proposes the batch for the current round.
This method performs the following steps:
- Drain the workers.
- Sign the batch.
- Set the batch proposal in the primary.
- Broadcast the batch header to all validators for signing.
Trait Implementations§
Auto Trait Implementations§
impl<N> !RefUnwindSafe for Primary<N>
impl<N> Send for Primary<N>
impl<N> Sync for Primary<N>
impl<N> Unpin for Primary<N>where <N as Environment>::Field: Unpin, <N as Environment>::Projective: Unpin, <N as Environment>::Scalar: Unpin,
impl<N> !UnwindSafe for Primary<N>
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