pub struct Worker<N: Network> { /* private fields */ }Implementations§
Source§impl<N: Network> Worker<N>
impl<N: Network> Worker<N>
Sourcepub fn new(
id: u8,
gateway: Arc<dyn Transport<N>>,
storage: Storage<N>,
ledger: Arc<dyn LedgerService<N>>,
proposed_batch: Arc<ProposedBatch<N>>,
) -> Result<Self>
pub fn new( id: u8, gateway: Arc<dyn Transport<N>>, storage: Storage<N>, ledger: Arc<dyn LedgerService<N>>, proposed_batch: Arc<ProposedBatch<N>>, ) -> Result<Self>
Initializes a new worker instance.
Sourcepub fn run(&self, receiver: WorkerReceiver<N>)
pub fn run(&self, receiver: WorkerReceiver<N>)
Run the worker instance.
Sourcepub fn pending(&self) -> &Arc<Pending<TransmissionID<N>, Transmission<N>>>
pub fn pending(&self) -> &Arc<Pending<TransmissionID<N>, Transmission<N>>>
Returns a reference to the pending transmissions queue.
Source§impl<N: Network> Worker<N>
impl<N: Network> Worker<N>
Sourcepub const MAX_TRANSMISSIONS_PER_WORKER: usize = 50usize
pub const MAX_TRANSMISSIONS_PER_WORKER: usize = 50usize
The maximum number of transmissions allowed in a worker.
Sourcepub const MAX_TRANSMISSIONS_PER_WORKER_PING: usize = 5usize
pub const MAX_TRANSMISSIONS_PER_WORKER_PING: usize = 5usize
The maximum number of transmissions allowed in a worker ping.
Sourcepub fn num_transmissions(&self) -> usize
pub fn num_transmissions(&self) -> usize
Returns the number of transmissions in the ready queue.
Sourcepub fn num_ratifications(&self) -> usize
pub fn num_ratifications(&self) -> usize
Returns the number of ratifications in the ready queue.
Sourcepub fn num_solutions(&self) -> usize
pub fn num_solutions(&self) -> usize
Returns the number of solutions in the ready queue.
Sourcepub fn num_transactions(&self) -> usize
pub fn num_transactions(&self) -> usize
Returns the number of transactions in the ready queue.
Source§impl<N: Network> Worker<N>
impl<N: Network> Worker<N>
Sourcepub fn transmission_ids(&self) -> IndexSet<TransmissionID<N>>
pub fn transmission_ids(&self) -> IndexSet<TransmissionID<N>>
Returns the transmission IDs in the ready queue.
Sourcepub fn transmissions(&self) -> IndexMap<TransmissionID<N>, Transmission<N>>
pub fn transmissions(&self) -> IndexMap<TransmissionID<N>, Transmission<N>>
Returns the transmissions in the ready queue.
Sourcepub fn solutions(
&self,
) -> impl '_ + Iterator<Item = (SolutionID<N>, Data<Solution<N>>)>
pub fn solutions( &self, ) -> impl '_ + Iterator<Item = (SolutionID<N>, Data<Solution<N>>)>
Returns the solutions in the ready queue.
Sourcepub fn transactions(
&self,
) -> impl '_ + Iterator<Item = (N::TransactionID, Data<Transaction<N>>)>
pub fn transactions( &self, ) -> impl '_ + Iterator<Item = (N::TransactionID, Data<Transaction<N>>)>
Returns the transactions in the ready queue.
Source§impl<N: Network> Worker<N>
impl<N: Network> Worker<N>
Sourcepub fn contains_transmission(
&self,
transmission_id: impl Into<TransmissionID<N>>,
) -> bool
pub fn contains_transmission( &self, transmission_id: impl Into<TransmissionID<N>>, ) -> bool
Returns true if the transmission ID exists in the ready queue, proposed batch, storage, or ledger.
Sourcepub fn get_transmission(
&self,
transmission_id: TransmissionID<N>,
) -> Option<Transmission<N>>
pub fn get_transmission( &self, transmission_id: TransmissionID<N>, ) -> Option<Transmission<N>>
Returns the transmission if it exists in the ready queue, proposed batch, storage.
Note: We explicitly forbid retrieving a transmission from the ledger, as transmissions in the ledger are not guaranteed to be invalid for the current batch.
Sourcepub async fn get_or_fetch_transmission(
&self,
peer_ip: SocketAddr,
transmission_id: TransmissionID<N>,
) -> Result<(TransmissionID<N>, Transmission<N>)>
pub async fn get_or_fetch_transmission( &self, peer_ip: SocketAddr, transmission_id: TransmissionID<N>, ) -> Result<(TransmissionID<N>, Transmission<N>)>
Returns the transmissions if it exists in the worker, or requests it from the specified peer.
Trait Implementations§
Auto Trait Implementations§
impl<N> Freeze for Worker<N>
impl<N> !RefUnwindSafe for Worker<N>
impl<N> Send for Worker<N>
impl<N> Sync for Worker<N>
impl<N> Unpin for Worker<N>
impl<N> !UnwindSafe for Worker<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