pub struct StubChainApi {
pub(crate) me: Address,
pub(crate) key_addr_map: BiMap<OffchainPublicKey, Address>,
pub(crate) channels: Vec<ChannelEntry>,
pub(crate) id_mapper: StubKeyIdMapper,
pub(crate) ticket_price: HoprBalance,
pub(crate) win_prob: WinningProbability,
}Expand description
Lightweight in-memory stub implementing the chain-API traits needed by
HoprEncoder / HoprDecoder / HoprTicketProcessor.
All lookups are simple BiMap or Vec scans — no async I/O, no database.
Fields§
§me: Address§key_addr_map: BiMap<OffchainPublicKey, Address>§channels: Vec<ChannelEntry>§id_mapper: StubKeyIdMapper§ticket_price: HoprBalance§win_prob: WinningProbabilityImplementations§
Source§impl StubChainApi
impl StubChainApi
Sourcepub fn builder() -> StubChainApiBuilder
pub fn builder() -> StubChainApiBuilder
Returns a new StubChainApiBuilder.
Sourcepub fn key_addr_map(&self) -> &BiMap<OffchainPublicKey, Address>
pub fn key_addr_map(&self) -> &BiMap<OffchainPublicKey, Address>
Returns the key-address mapping.
Trait Implementations§
Source§impl ChainKeyOperations for StubChainApi
impl ChainKeyOperations for StubChainApi
type Error = StubError
Source§type Mapper = StubKeyIdMapper
type Mapper = StubKeyIdMapper
Source§fn chain_key_to_packet_key(
&self,
chain: &Address,
) -> Result<Option<OffchainPublicKey>, Self::Error>
fn chain_key_to_packet_key( &self, chain: &Address, ) -> Result<Option<OffchainPublicKey>, Self::Error>
Translates [
Address] into [OffchainPublicKey].Source§fn packet_key_to_chain_key(
&self,
packet: &OffchainPublicKey,
) -> Result<Option<Address>, Self::Error>
fn packet_key_to_chain_key( &self, packet: &OffchainPublicKey, ) -> Result<Option<Address>, Self::Error>
Translates [
OffchainPublicKey] into [Address].Source§fn key_id_mapper_ref(&self) -> &Self::Mapper
fn key_id_mapper_ref(&self) -> &Self::Mapper
Returns a reference to [
KeyIdMapping] for offchain key IDs.Source§impl ChainReadChannelOperations for StubChainApi
impl ChainReadChannelOperations for StubChainApi
type Error = StubError
Source§fn channel_by_id(
&self,
channel_id: &ChannelId,
) -> Result<Option<ChannelEntry>, Self::Error>
fn channel_by_id( &self, channel_id: &ChannelId, ) -> Result<Option<ChannelEntry>, Self::Error>
Returns a single channel given
channel_id.Source§fn stream_channels<'a>(
&'a self,
_selector: ChannelSelector,
) -> Result<BoxStream<'a, ChannelEntry>, Self::Error>
fn stream_channels<'a>( &'a self, _selector: ChannelSelector, ) -> Result<BoxStream<'a, ChannelEntry>, Self::Error>
Returns a stream of channels given the [
ChannelSelector].§fn channel_by_parties(
&self,
src: &Address,
dst: &Address,
) -> Result<Option<ChannelEntry>, Self::Error>
fn channel_by_parties( &self, src: &Address, dst: &Address, ) -> Result<Option<ChannelEntry>, Self::Error>
Returns a single channel given
src and dst.Source§impl ChainReadTicketOperations for StubChainApi
impl ChainReadTicketOperations for StubChainApi
type Error = StubError
Source§fn outgoing_ticket_values(
&self,
configured_wp: Option<WinningProbability>,
configured_price: Option<HoprBalance>,
) -> Result<(WinningProbability, HoprBalance), Self::Error>
fn outgoing_ticket_values( &self, configured_wp: Option<WinningProbability>, configured_price: Option<HoprBalance>, ) -> Result<(WinningProbability, HoprBalance), Self::Error>
Retrieves the winning probability and ticket price for outgoing tickets,
with respect to the optionally pre-configured values. Read more
Source§fn incoming_ticket_values(
&self,
) -> Result<(WinningProbability, HoprBalance), Self::Error>
fn incoming_ticket_values( &self, ) -> Result<(WinningProbability, HoprBalance), Self::Error>
Retrieves the expected minimum winning probability and ticket price for incoming tickets. Read more
Source§impl ChainValues for StubChainApi
impl ChainValues for StubChainApi
type Error = StubError
Source§fn balance<'life0, 'async_trait, C, A>(
&'life0 self,
_address: A,
) -> Pin<Box<dyn Future<Output = Result<Balance<C>, Self::Error>> + Send + 'async_trait>>
fn balance<'life0, 'async_trait, C, A>( &'life0 self, _address: A, ) -> Pin<Box<dyn Future<Output = Result<Balance<C>, Self::Error>> + Send + 'async_trait>>
Returns the native or token currency balance of the given on-chain account.
Source§fn domain_separators<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<DomainSeparators, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn domain_separators<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<DomainSeparators, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Retrieves the domain separators of HOPR smart contracts.
Source§fn minimum_incoming_ticket_win_prob<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<WinningProbability, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn minimum_incoming_ticket_win_prob<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<WinningProbability, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Retrieves the network-set minimum incoming ticket winning probability.
Source§fn minimum_ticket_price<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<HoprBalance, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn minimum_ticket_price<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<HoprBalance, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Retrieves the network-set minimum ticket price.
Source§fn key_binding_fee<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<HoprBalance, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn key_binding_fee<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<HoprBalance, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Retrieves the current key binding fee
used for new key-binding announcements.
Source§fn channel_closure_notice_period<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Duration, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn channel_closure_notice_period<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Duration, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Gets the grace period for channel closure finalization.
Source§fn chain_info<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<ChainInfo, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn chain_info<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<ChainInfo, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Gets the information about the HOPR network on-chain deployment.
Source§impl Clone for StubChainApi
impl Clone for StubChainApi
Source§fn clone(&self) -> StubChainApi
fn clone(&self) -> StubChainApi
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for StubChainApi
impl RefUnwindSafe for StubChainApi
impl Send for StubChainApi
impl Sync for StubChainApi
impl Unpin for StubChainApi
impl UnwindSafe for StubChainApi
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
Mutably borrows from an owned value. Read more
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>
Converts
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>
Converts
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