Trait breez_sdk_core::lightning::events::EventsProvider

pub trait EventsProvider {
    // Required method
    fn process_pending_events<H>(&self, handler: H)
       where H: Deref,
             <H as Deref>::Target: EventHandler;
}
Expand description

A trait indicating an object may generate events.

Events are processed by passing an EventHandler to process_pending_events.

Implementations of this trait may also feature an async version of event handling, as shown with ChannelManager::process_pending_events_async and ChainMonitor::process_pending_events_async.

§Requirements

When using this trait, process_pending_events will call handle_event for each pending event since the last invocation.

In order to ensure no Events are lost, implementors of this trait will persist Events and replay any unhandled events on startup. An Event is considered handled when process_pending_events returns, thus handlers MUST fully handle Events and persist any relevant changes to disk before returning.

Further, because an application may crash between an Event being handled and the implementor of this trait being re-serialized, Event handling must be idempotent - in effect, Events may be replayed.

Note, handlers may call back into the provider and thus deadlocking must be avoided. Be sure to consult the provider’s documentation on the implication of processing events and how a handler may safely use the provider (e.g., see ChannelManager::process_pending_events and ChainMonitor::process_pending_events).

(C-not implementable) As there is likely no reason for a user to implement this trait on their own type(s).

Required Methods§

fn process_pending_events<H>(&self, handler: H)
where H: Deref, <H as Deref>::Target: EventHandler,

Processes any events generated since the last call using the given event handler.

See the trait-level documentation for requirements.

Object Safety§

This trait is not object safe.

Implementors§

§

impl<ChannelSigner, C, T, F, L, P> EventsProvider for ChainMonitor<ChannelSigner, C, T, F, L, P>
where ChannelSigner: WriteableEcdsaChannelSigner, C: Deref, T: Deref, F: Deref, L: Deref, P: Deref, <C as Deref>::Target: Filter, <T as Deref>::Target: BroadcasterInterface, <F as Deref>::Target: FeeEstimator, <L as Deref>::Target: Logger, <P as Deref>::Target: Persist<ChannelSigner>,

§

impl<M, T, ES, NS, SP, F, R, L> EventsProvider for ChannelManager<M, T, ES, NS, SP, F, R, L>
where M: Deref, T: Deref, ES: Deref, NS: Deref, SP: Deref, F: Deref, R: Deref, L: Deref, <M as Deref>::Target: Watch<<<SP as Deref>::Target as SignerProvider>::Signer>, <T as Deref>::Target: BroadcasterInterface, <ES as Deref>::Target: EntropySource, <NS as Deref>::Target: NodeSigner, <SP as Deref>::Target: SignerProvider, <F as Deref>::Target: FeeEstimator, <R as Deref>::Target: Router, <L as Deref>::Target: Logger,