pub struct Primary<N: Network> { /* private fields */ }Expand description
The primary logic of a node. AleoBFT adopts a primary-worker architecture as described in the Narwhal and Tusk paper (Section 4.2).
Implementations§
Source§impl<N: Network> Primary<N>
impl<N: Network> Primary<N>
Sourcepub const MAX_TRANSMISSIONS_TOLERANCE: usize = 100usize
pub const MAX_TRANSMISSIONS_TOLERANCE: usize = 100usize
The maximum number of unconfirmed transmissions to send to the primary.
Sourcepub fn new(
account: Account<N>,
storage: Storage<N>,
ledger: Arc<dyn LedgerService<N>>,
block_sync: Arc<BlockSync<N>>,
ip: Option<SocketAddr>,
trusted_validators: &[SocketAddr],
trusted_peers_only: bool,
storage_mode: StorageMode,
dev: Option<u16>,
) -> Result<Self>
pub fn new( account: Account<N>, storage: Storage<N>, ledger: Arc<dyn LedgerService<N>>, block_sync: Arc<BlockSync<N>>, ip: Option<SocketAddr>, trusted_validators: &[SocketAddr], trusted_peers_only: bool, storage_mode: StorageMode, dev: Option<u16>, ) -> Result<Self>
Initializes a new primary instance.
Sourcepub async fn run(
&mut self,
ping: Option<Arc<Ping<N>>>,
bft_sender: Option<BFTSender<N>>,
primary_sender: PrimarySender<N>,
primary_receiver: PrimaryReceiver<N>,
) -> Result<()>
pub async fn run( &mut self, ping: Option<Arc<Ping<N>>>, 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 unconfirmed 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 worker_transmission_ids(
&self,
) -> impl '_ + Iterator<Item = TransmissionID<N>>
pub fn worker_transmission_ids( &self, ) -> impl '_ + Iterator<Item = TransmissionID<N>>
Returns the worker transmission IDs.
Sourcepub fn worker_transmissions(
&self,
) -> impl '_ + Iterator<Item = (TransmissionID<N>, Transmission<N>)>
pub fn worker_transmissions( &self, ) -> impl '_ + Iterator<Item = (TransmissionID<N>, Transmission<N>)>
Returns the worker transmissions.
Sourcepub fn worker_solutions(
&self,
) -> impl '_ + Iterator<Item = (SolutionID<N>, Data<Solution<N>>)>
pub fn worker_solutions( &self, ) -> impl '_ + Iterator<Item = (SolutionID<N>, Data<Solution<N>>)>
Returns the worker solutions.
Sourcepub fn worker_transactions(
&self,
) -> impl '_ + Iterator<Item = (N::TransactionID, Data<Transaction<N>>)>
pub fn worker_transactions( &self, ) -> impl '_ + Iterator<Item = (N::TransactionID, Data<Transaction<N>>)>
Returns the worker transactions.
Source§impl<N: Network> Primary<N>
impl<N: Network> Primary<N>
Sourcepub fn clear_worker_solutions(&self)
pub fn clear_worker_solutions(&self)
Clears the worker solutions.
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> Freeze for Primary<N>
impl<N> !RefUnwindSafe for Primary<N>
impl<N> Send for Primary<N>
impl<N> Sync for Primary<N>
impl<N> Unpin for Primary<N>
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more