Skip to main content

WalletMonitorTask

Trait WalletMonitorTask 

Source
pub trait WalletMonitorTask: Send + Sync {
    // Required methods
    fn name(&self) -> &str;
    fn trigger(&mut self, now_msecs: u64) -> bool;
    fn run_task<'life0, 'async_trait>(
        &'life0 mut self,
    ) -> Pin<Box<dyn Future<Output = Result<String, WalletError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;

    // Provided method
    fn async_setup<'life0, 'async_trait>(
        &'life0 mut self,
    ) -> Pin<Box<dyn Future<Output = Result<(), WalletError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait { ... }
}
Expand description

A monitor task performs some periodic or state-triggered maintenance function on the data managed by a wallet.

The monitor maintains a collection of tasks. It runs each task’s non-async trigger to determine if run_task needs to run. Tasks that need to be run are executed consecutively by awaiting their async run_task method.

Tasks may use the monitor_events table to persist their execution history via the storage object.

Required Methods§

Source

fn name(&self) -> &str

Returns the name of this task (used for logging and lookup).

Source

fn trigger(&mut self, now_msecs: u64) -> bool

Return true if run_task needs to be called now. This is NOT async – it must be a fast, synchronous check.

Source

fn run_task<'life0, 'async_trait>( &'life0 mut self, ) -> Pin<Box<dyn Future<Output = Result<String, WalletError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Execute the task’s work. Returns a log string describing what was done.

Provided Methods§

Source

fn async_setup<'life0, 'async_trait>( &'life0 mut self, ) -> Pin<Box<dyn Future<Output = Result<(), WalletError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Override to handle async task setup configuration. Called before the first call to trigger.

Implementors§