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§
sourcefn wait_for_draws(&self, cycle: u64) -> PosResult<u64>
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.
sourcefn feed_cycle(
&self,
cycle: u64,
lookback_rolls: BTreeMap<Address, u64>,
lookback_seed: Hash,
) -> PosResult<()>
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 drawnlookback_rolls
: look back rolls used for the draw (cycle - 3)lookback_seed
: look back seed hash for the draw (cycle - 2)
sourcefn get_selection(&self, slot: Slot) -> PosResult<Selection>
fn get_selection(&self, slot: Slot) -> PosResult<Selection>
Get Selection computed for a slot
sourcefn get_producer(&self, slot: Slot) -> PosResult<Address>
fn get_producer(&self, slot: Slot) -> PosResult<Address>
Get [Address] of the selected block producer for a given slot
sourcefn get_available_selections_in_range<'a>(
&self,
slot_range: RangeInclusive<Slot>,
restrict_to_addresses: Option<&'a PreHashSet<Address>>,
) -> PosResult<BTreeMap<Slot, Selection>>
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 forrestrict_to_addresses
: optionally restrict only to slots involving a given address
sourcefn clone_box(&self) -> Box<dyn SelectorController>
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>
impl Clone for Box<dyn SelectorController>
Allow cloning Box<dyn SelectorController>
Uses ExecutionController::clone_box
internally