pub struct HoprChain<T: HoprDbAllOperations + Send + Sync + Clone + Debug> { /* private fields */ }
Expand description
Represents all chain interactions exported to be used in the hopr-lib
NOTE: instead of creating a unified interface the HoprChain exports some functionality (e.g. the ChainActions as a referentially used) object. This behavior will be refactored and hidden behind a trait in the future implementations.
Implementations§
Source§impl<T: HoprDbAllOperations + Send + Sync + Clone + Debug + 'static> HoprChain<T>
impl<T: HoprDbAllOperations + Send + Sync + Clone + Debug + 'static> HoprChain<T>
pub fn new( me_onchain: ChainKeypair, db: T, chain_config: ChainNetworkConfig, module_address: Address, contract_addresses: ContractAddresses, safe_address: Address, indexer_cfg: IndexerConfig, indexer_events_tx: Sender<SignificantChainEvent>, ) -> Result<Self>
Sourcepub async fn start(&self) -> Result<HashMap<HoprChainProcess, AbortHandle>>
pub async fn start(&self) -> Result<HashMap<HoprChainProcess, AbortHandle>>
Execute all processes of the HoprChain
object.
This method will spawn the HoprChainProcess::Indexer
and HoprChainProcess::OutgoingOnchainActionQueue
processes and return join handles to the calling function.
pub fn me_onchain(&self) -> Address
pub fn action_state(&self) -> Arc<IndexerActionTracker>
pub async fn accounts_announced_on_chain(&self) -> Result<Vec<AccountEntry>>
pub async fn channel( &self, src: &Address, dest: &Address, ) -> Result<ChannelEntry>
pub async fn channels_from(&self, src: &Address) -> Result<Vec<ChannelEntry>>
pub async fn channels_to(&self, dest: &Address) -> Result<Vec<ChannelEntry>>
pub async fn all_channels(&self) -> Result<Vec<ChannelEntry>>
pub async fn corrupted_channels(&self) -> Result<Vec<CorruptedChannelEntry>>
pub async fn ticket_price(&self) -> Result<Option<HoprBalance>>
pub async fn safe_allowance(&self) -> Result<HoprBalance>
pub fn actions_ref(&self) -> &ChainActions<T>
pub fn actions_mut_ref(&mut self) -> &mut ChainActions<T>
pub fn rpc(&self) -> &RpcOperations<DefaultHttpRequestor>
Sourcepub async fn get_balance<C: Currency + Send>(&self) -> Result<Balance<C>>
pub async fn get_balance<C: Currency + Send>(&self) -> Result<Balance<C>>
Retrieves the balance of the node’s on-chain account for the specified currency.
This method queries the on-chain balance of the node’s account for the given currency. It supports querying balances for XDai and WxHOPR currencies. If the currency is unsupported, an error is returned.
§Returns
Result<Balance<C>>
- The balance of the node’s account for the specified currency, or an error if the query fails.
Sourcepub async fn get_safe_balance<C: Currency + Send>(
&self,
safe_address: Address,
) -> Result<Balance<C>>
pub async fn get_safe_balance<C: Currency + Send>( &self, safe_address: Address, ) -> Result<Balance<C>>
Retrieves the balance of the specified address for the given currency.
This method queries the on-chain balance of the provided address for the specified currency. It supports querying balances for XDai and WxHOPR currencies. If the currency is unsupported, an error is returned.
§Arguments
address
- The address whose balance is to be retrieved.
§Returns
Result<Balance<C>>
- The balance of the specified address for the given currency, or an error if the query fails.
Sourcepub async fn get_safe_hopr_allowance(&self) -> Result<HoprBalance>
pub async fn get_safe_hopr_allowance(&self) -> Result<HoprBalance>
Retrieves the HOPR token allowance granted by the safe address to the channels contract.
This method queries the on-chain HOPR token contract to determine how many tokens the safe address has approved the channels contract to spend on its behalf.
§Returns
Result<HoprBalance>
- The current allowance amount, or an error if the query fails
pub async fn get_channel_closure_notice_period(&self) -> Result<Duration>
pub async fn get_eligibility_status(&self) -> Result<bool>
pub async fn get_minimum_winning_probability( &self, ) -> Result<WinningProbability>
pub async fn get_minimum_ticket_price(&self) -> Result<HoprBalance>
Trait Implementations§
Auto Trait Implementations§
impl<T> Freeze for HoprChain<T>where
T: Freeze,
impl<T> !RefUnwindSafe for HoprChain<T>
impl<T> Send for HoprChain<T>
impl<T> Sync for HoprChain<T>
impl<T> !Unpin for HoprChain<T>
impl<T> !UnwindSafe for HoprChain<T>
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