pub trait SelectorController: Send + Sync {
    // Required methods
    fn wait_for_draws(&self, cycle: u64) -> PosResult<u64>;
    fn feed_cycle(
        &self,
        cycle: u64,
        lookback_rolls: BTreeMap<Address, u64>,
        lookback_seed: Hash
    ) -> PosResult<()>;
    fn get_selection(&self, slot: Slot) -> PosResult<Selection>;
    fn get_producer(&self, slot: Slot) -> PosResult<Address>;
    fn get_available_selections_in_range<'a>(
        &self,
        slot_range: RangeInclusive<Slot>,
        restrict_to_addresses: Option<&'a PreHashSet<Address>>
    ) -> PosResult<BTreeMap<Slot, Selection>>;
    fn clone_box(&self) -> Box<dyn SelectorController>;
}
Expand description

interface that communicates with the selector worker thread

Required Methods§

source

fn wait_for_draws(&self, cycle: u64) -> PosResult<u64>

Waits for draws to reach at least a given cycle number. Returns the latest cycle number reached (can be higher than cycle). Errors can occur if the thread stopped.

source

fn feed_cycle( &self, cycle: u64, lookback_rolls: BTreeMap<Address, u64>, lookback_seed: Hash ) -> PosResult<()>

Feed cycle to the selector

Arguments
  • cycle: cycle number to be drawn
  • lookback_rolls: look back rolls used for the draw (cycle - 3)
  • lookback_seed: look back seed hash for the draw (cycle - 2)
source

fn get_selection(&self, slot: Slot) -> PosResult<Selection>

Get Selection computed for a slot

source

fn get_producer(&self, slot: Slot) -> PosResult<Address>

Get Address of the selected block producer for a given slot

source

fn get_available_selections_in_range<'a>( &self, slot_range: RangeInclusive<Slot>, restrict_to_addresses: Option<&'a PreHashSet<Address>> ) -> PosResult<BTreeMap<Slot, Selection>>

Get selections computed for a slot range (only returns available selections):

Arguments
  • slot_range: range of slots to get the selection for
  • restrict_to_addresses: optionally restrict only to slots involving a given address
source

fn clone_box(&self) -> Box<dyn SelectorController>

Returns a boxed clone of self. Useful to allow cloning Box<dyn SelectorController>.

Trait Implementations§

source§

impl Clone for Box<dyn SelectorController>

Allow cloning Box<dyn SelectorController> Uses ExecutionController::clone_box internally

source§

fn clone(&self) -> Box<dyn SelectorController>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

Implementors§