Struct snarkos_node_bft::Worker
source · 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.
source§impl<N: Network> Worker<N>
impl<N: Network> Worker<N>
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 = (PuzzleCommitment<N>, Data<ProverSolution<N>>)>
pub fn solutions( &self ) -> impl '_ + Iterator<Item = (PuzzleCommitment<N>, Data<ProverSolution<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.