pub struct TicketSelector {
pub channel_identifier: (ChannelId, u32),
pub index: TicketIndexSelector,
pub win_prob: (Bound<WinningProbability>, Bound<WinningProbability>),
pub amount: (Bound<HoprBalance>, Bound<HoprBalance>),
pub state: Option<AcknowledgedTicketStatus>,
}Expand description
Allows selecting tickets via HoprDbTicketOperations.
The TicketSelector always allows selecting only tickets in a single channel.
To select tickets across multiple channels, multiple TicketSelectors must be used.
Fields§
§channel_identifier: (ChannelId, u32)Channel ID and Epoch pair.
index: TicketIndexSelectorIf given, will select ticket(s) with the given indices in the given channel and epoch.
See TicketIndexSelector for possible options.
win_prob: (Bound<WinningProbability>, Bound<WinningProbability>)If given, the tickets are further restricted to the ones with a winning probability in this range.
amount: (Bound<HoprBalance>, Bound<HoprBalance>)If given, the tickets are further restricted to the ones with an amount in this range.
state: Option<AcknowledgedTicketStatus>Further restriction to tickets with the given state.
Implementations§
Source§impl TicketSelector
impl TicketSelector
Sourcepub fn new(channel_id: ChannelId, epoch: u32) -> Self
pub fn new(channel_id: ChannelId, epoch: u32) -> Self
Create a new ticket selector given the channel_id and epoch.
Sourcepub fn is_unique(&self) -> bool
pub fn is_unique(&self) -> bool
If false is returned, the selector can fetch more than a single ticket.
Sourcepub fn with_index(self, index: u64) -> Self
pub fn with_index(self, index: u64) -> Self
Returns this instance with a ticket index set.
This method can be called multiple times to select multiple tickets.
If TicketSelector::with_index_range was previously called, it will be replaced.
Sourcepub fn with_index_range<T: RangeBounds<u64>>(self, index_bound: T) -> Self
pub fn with_index_range<T: RangeBounds<u64>>(self, index_bound: T) -> Self
Returns this instance with a ticket index upper bound set.
If TicketSelector::with_index was previously called, it will be replaced.
Sourcepub fn with_state(self, state: AcknowledgedTicketStatus) -> Self
pub fn with_state(self, state: AcknowledgedTicketStatus) -> Self
Returns this instance with a ticket state set.
Sourcepub fn with_no_state(self) -> Self
pub fn with_no_state(self) -> Self
Returns this instance without a ticket state set.
Sourcepub fn with_winning_probability<T: RangeBounds<WinningProbability>>(
self,
range: T,
) -> Self
pub fn with_winning_probability<T: RangeBounds<WinningProbability>>( self, range: T, ) -> Self
Returns this instance with a winning probability range bounds set.
Sourcepub fn with_amount<T: RangeBounds<HoprBalance>>(self, range: T) -> Self
pub fn with_amount<T: RangeBounds<HoprBalance>>(self, range: T) -> Self
Returns this instance with the ticket amount range bounds set.
Trait Implementations§
Source§impl Clone for TicketSelector
impl Clone for TicketSelector
Source§fn clone(&self) -> TicketSelector
fn clone(&self) -> TicketSelector
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for TicketSelector
impl Debug for TicketSelector
Source§impl Display for TicketSelector
impl Display for TicketSelector
Source§impl From<&AcknowledgedTicket> for TicketSelector
impl From<&AcknowledgedTicket> for TicketSelector
Source§fn from(value: &AcknowledgedTicket) -> Self
fn from(value: &AcknowledgedTicket) -> Self
Source§impl From<&ChannelEntry> for TicketSelector
impl From<&ChannelEntry> for TicketSelector
Source§fn from(value: &ChannelEntry) -> Self
fn from(value: &ChannelEntry) -> Self
Source§impl From<&RedeemableTicket> for TicketSelector
impl From<&RedeemableTicket> for TicketSelector
Source§fn from(value: &RedeemableTicket) -> Self
fn from(value: &RedeemableTicket) -> Self
Source§impl From<&VerifiedTicket> for TicketSelector
impl From<&VerifiedTicket> for TicketSelector
Source§fn from(value: &VerifiedTicket) -> Self
fn from(value: &VerifiedTicket) -> Self
Source§impl From<ChannelEntry> for TicketSelector
impl From<ChannelEntry> for TicketSelector
Source§fn from(value: ChannelEntry) -> Self
fn from(value: ChannelEntry) -> Self
Source§impl PartialEq for TicketSelector
impl PartialEq for TicketSelector
Auto Trait Implementations§
impl Freeze for TicketSelector
impl RefUnwindSafe for TicketSelector
impl Send for TicketSelector
impl Sync for TicketSelector
impl Unpin for TicketSelector
impl UnwindSafe for TicketSelector
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,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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§impl<T> Pointable for T
impl<T> Pointable for T
§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
§impl<T> ToStringFallible for Twhere
T: Display,
impl<T> ToStringFallible for Twhere
T: Display,
§fn try_to_string(&self) -> Result<String, TryReserveError>
fn try_to_string(&self) -> Result<String, TryReserveError>
ToString::to_string, but without panic on OOM.