1 // This file is Copyright its original authors, visible in version control
4 // This file is licensed under the Apache License, Version 2.0 <LICENSE-APACHE
5 // or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
6 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option.
7 // You may not use this file except in accordance with one or both of these
10 //! Events are returned from various bits in the library which indicate some action must be taken
13 //! Because we don't have a built-in runtime, it's up to the client to call events at a time in the
14 //! future, as well as generate and broadcast funding transactions handle payment preimages and a
17 use chain::keysinterface::SpendableOutputDescriptor;
19 use ln::msgs::DecodeError;
20 use ln::{PaymentPreimage, PaymentHash, PaymentSecret};
21 use routing::network_graph::NetworkUpdate;
22 use util::ser::{BigSize, FixedLengthReader, Writeable, Writer, MaybeReadable, Readable, VecReadWrapper, VecWriteWrapper};
23 use routing::router::RouteHop;
25 use bitcoin::blockdata::script::Script;
27 use bitcoin::secp256k1::key::PublicKey;
31 use core::time::Duration;
34 /// Some information provided on receipt of payment depends on whether the payment received is a
35 /// spontaneous payment or a "conventional" lightning payment that's paying an invoice.
36 #[derive(Clone, Debug)]
37 pub enum PaymentPurpose {
38 /// Information for receiving a payment that we generated an invoice for.
40 /// The preimage to the payment_hash, if the payment hash (and secret) were fetched via
41 /// [`ChannelManager::create_inbound_payment`]. If provided, this can be handed directly to
42 /// [`ChannelManager::claim_funds`].
44 /// [`ChannelManager::create_inbound_payment`]: crate::ln::channelmanager::ChannelManager::create_inbound_payment
45 /// [`ChannelManager::claim_funds`]: crate::ln::channelmanager::ChannelManager::claim_funds
46 payment_preimage: Option<PaymentPreimage>,
47 /// The "payment secret". This authenticates the sender to the recipient, preventing a
48 /// number of deanonymization attacks during the routing process.
49 /// It is provided here for your reference, however its accuracy is enforced directly by
50 /// [`ChannelManager`] using the values you previously provided to
51 /// [`ChannelManager::create_inbound_payment`] or
52 /// [`ChannelManager::create_inbound_payment_for_hash`].
54 /// [`ChannelManager`]: crate::ln::channelmanager::ChannelManager
55 /// [`ChannelManager::create_inbound_payment`]: crate::ln::channelmanager::ChannelManager::create_inbound_payment
56 /// [`ChannelManager::create_inbound_payment_for_hash`]: crate::ln::channelmanager::ChannelManager::create_inbound_payment_for_hash
57 payment_secret: PaymentSecret,
58 /// This is the `user_payment_id` which was provided to
59 /// [`ChannelManager::create_inbound_payment_for_hash`] or
60 /// [`ChannelManager::create_inbound_payment`]. It has no meaning inside of LDK and is
61 /// simply copied here. It may be used to correlate PaymentReceived events with invoice
62 /// metadata stored elsewhere.
64 /// [`ChannelManager::create_inbound_payment`]: crate::ln::channelmanager::ChannelManager::create_inbound_payment
65 /// [`ChannelManager::create_inbound_payment_for_hash`]: crate::ln::channelmanager::ChannelManager::create_inbound_payment_for_hash
68 /// Because this is a spontaneous payment, the payer generated their own preimage rather than us
69 /// (the payee) providing a preimage.
70 SpontaneousPayment(PaymentPreimage),
73 #[derive(Clone, Debug, PartialEq)]
74 /// The reason the channel was closed. See individual variants more details.
75 pub enum ClosureReason {
76 /// Closure generated from receiving a peer error message.
78 /// Our counterparty may have broadcasted their latest commitment state, and we have
80 CounterpartyForceClosed {
81 /// The error which the peer sent us.
83 /// The string should be sanitized before it is used (e.g emitted to logs
84 /// or printed to stdout). Otherwise, a well crafted error message may exploit
85 /// a security vulnerability in the terminal emulator or the logging subsystem.
88 /// Closure generated from [`ChannelManager::force_close_channel`], called by the user.
90 /// [`ChannelManager::force_close_channel`]: crate::ln::channelmanager::ChannelManager::force_close_channel.
92 /// The channel was closed after negotiating a cooperative close and we've now broadcasted
93 /// the cooperative close transaction. Note the shutdown may have been initiated by us.
94 //TODO: split between CounterpartyInitiated/LocallyInitiated
96 /// A commitment transaction was confirmed on chain, closing the channel. Most likely this
97 /// commitment transaction came from our counterparty, but it may also have come from
98 /// a copy of our own `ChannelMonitor`.
99 CommitmentTxConfirmed,
100 /// Closure generated from processing an event, likely a HTLC forward/relay/reception.
102 /// A developer-readable error message which we generated.
105 /// The `PeerManager` informed us that we've disconnected from the peer. We close channels
106 /// if the `PeerManager` informed us that it is unlikely we'll be able to connect to the
107 /// peer again in the future or if the peer disconnected before we finished negotiating
108 /// the channel open. The first case may be caused by incompatible features which our
109 /// counterparty, or we, require.
110 //TODO: split between PeerUnconnectable/PeerDisconnected ?
112 /// Closure generated from `ChannelManager::read` if the ChannelMonitor is newer than
113 /// the ChannelManager deserialized.
114 OutdatedChannelManager
117 impl_writeable_tlv_based_enum_upgradable!(ClosureReason,
118 (0, CounterpartyForceClosed) => { (1, peer_msg, required) },
119 (2, HolderForceClosed) => {},
120 (6, CommitmentTxConfirmed) => {},
121 (4, CooperativeClosure) => {},
122 (8, ProcessingError) => { (1, err, required) },
123 (10, DisconnectedPeer) => {},
124 (12, OutdatedChannelManager) => {},
127 /// An Event which you should probably take some action in response to.
129 /// Note that while Writeable and Readable are implemented for Event, you probably shouldn't use
130 /// them directly as they don't round-trip exactly (for example FundingGenerationReady is never
131 /// written as it makes no sense to respond to it after reconnecting to peers).
132 #[derive(Clone, Debug)]
134 /// Used to indicate that the client should generate a funding transaction with the given
135 /// parameters and then call ChannelManager::funding_transaction_generated.
136 /// Generated in ChannelManager message handling.
137 /// Note that *all inputs* in the funding transaction must spend SegWit outputs or your
138 /// counterparty can steal your funds!
139 FundingGenerationReady {
140 /// The random channel_id we picked which you'll need to pass into
141 /// ChannelManager::funding_transaction_generated.
142 temporary_channel_id: [u8; 32],
143 /// The value, in satoshis, that the output should have.
144 channel_value_satoshis: u64,
145 /// The script which should be used in the transaction output.
146 output_script: Script,
147 /// The value passed in to ChannelManager::create_channel
148 user_channel_id: u64,
150 /// Indicates we've received money! Just gotta dig out that payment preimage and feed it to
151 /// ChannelManager::claim_funds to get it....
152 /// Note that if the preimage is not known or the amount paid is incorrect, you should call
153 /// ChannelManager::fail_htlc_backwards to free up resources for this HTLC and avoid
154 /// network congestion.
155 /// The amount paid should be considered 'incorrect' when it is less than or more than twice
156 /// the amount expected.
157 /// If you fail to call either ChannelManager::claim_funds or
158 /// ChannelManager::fail_htlc_backwards within the HTLC's timeout, the HTLC will be
159 /// automatically failed.
161 /// The hash for which the preimage should be handed to the ChannelManager.
162 payment_hash: PaymentHash,
163 /// The value, in thousandths of a satoshi, that this payment is for. Note that you must
164 /// compare this to the expected value before accepting the payment (as otherwise you are
165 /// providing proof-of-payment for less than the value you expected!).
167 /// Information for claiming this received payment, based on whether the purpose of the
168 /// payment is to pay an invoice or to send a spontaneous payment.
169 purpose: PaymentPurpose,
171 /// Indicates an outbound payment we made succeeded (i.e. it made it all the way to its target
172 /// and we got back the payment preimage for it).
174 /// Note for MPP payments: in rare cases, this event may be preceded by a `PaymentPathFailed`
175 /// event. In this situation, you SHOULD treat this payment as having succeeded.
177 /// The preimage to the hash given to ChannelManager::send_payment.
178 /// Note that this serves as a payment receipt, if you wish to have such a thing, you must
179 /// store it somehow!
180 payment_preimage: PaymentPreimage,
182 /// Indicates an outbound payment we made failed. Probably some intermediary node dropped
183 /// something. You may wish to retry with a different route.
185 /// The hash which was given to ChannelManager::send_payment.
186 payment_hash: PaymentHash,
187 /// Indicates the payment was rejected for some reason by the recipient. This implies that
188 /// the payment has failed, not just the route in question. If this is not set, you may
189 /// retry the payment via a different route.
190 rejected_by_dest: bool,
191 /// Any failure information conveyed via the Onion return packet by a node along the failed
194 /// Should be applied to the [`NetworkGraph`] so that routing decisions can take into
195 /// account the update. [`NetGraphMsgHandler`] is capable of doing this.
197 /// [`NetworkGraph`]: crate::routing::network_graph::NetworkGraph
198 /// [`NetGraphMsgHandler`]: crate::routing::network_graph::NetGraphMsgHandler
199 network_update: Option<NetworkUpdate>,
200 /// For both single-path and multi-path payments, this is set if all paths of the payment have
201 /// failed. This will be set to false if (1) this is an MPP payment and (2) other parts of the
202 /// larger MPP payment were still in flight when this event was generated.
203 all_paths_failed: bool,
204 /// The payment path that failed.
207 error_code: Option<u16>,
209 error_data: Option<Vec<u8>>,
211 /// Used to indicate that ChannelManager::process_pending_htlc_forwards should be called at a
212 /// time in the future.
213 PendingHTLCsForwardable {
214 /// The minimum amount of time that should be waited prior to calling
215 /// process_pending_htlc_forwards. To increase the effort required to correlate payments,
216 /// you should wait a random amount of time in roughly the range (now + time_forwardable,
217 /// now + 5*time_forwardable).
218 time_forwardable: Duration,
220 /// Used to indicate that an output which you should know how to spend was confirmed on chain
221 /// and is now spendable.
222 /// Such an output will *not* ever be spent by rust-lightning, and are not at risk of your
223 /// counterparty spending them due to some kind of timeout. Thus, you need to store them
224 /// somewhere and spend them when you create on-chain transactions.
226 /// The outputs which you should store as spendable by you.
227 outputs: Vec<SpendableOutputDescriptor>,
229 /// This event is generated when a payment has been successfully forwarded through us and a
230 /// forwarding fee earned.
232 /// The fee, in milli-satoshis, which was earned as a result of the payment.
234 /// Note that if we force-closed the channel over which we forwarded an HTLC while the HTLC
235 /// was pending, the amount the next hop claimed will have been rounded down to the nearest
236 /// whole satoshi. Thus, the fee calculated here may be higher than expected as we still
237 /// claimed the full value in millisatoshis from the source. In this case,
238 /// `claim_from_onchain_tx` will be set.
240 /// If the channel which sent us the payment has been force-closed, we will claim the funds
241 /// via an on-chain transaction. In that case we do not yet know the on-chain transaction
242 /// fees which we will spend and will instead set this to `None`. It is possible duplicate
243 /// `PaymentForwarded` events are generated for the same payment iff `fee_earned_msat` is
245 fee_earned_msat: Option<u64>,
246 /// If this is `true`, the forwarded HTLC was claimed by our counterparty via an on-chain
248 claim_from_onchain_tx: bool,
250 /// Used to indicate that a channel with the given `channel_id` is in the process of closure.
252 /// The channel_id of the channel which has been closed. Note that on-chain transactions
253 /// resolving the channel are likely still awaiting confirmation.
254 channel_id: [u8; 32],
255 /// The reason the channel was closed.
256 reason: ClosureReason
260 impl Writeable for Event {
261 fn write<W: Writer>(&self, writer: &mut W) -> Result<(), io::Error> {
263 &Event::FundingGenerationReady { .. } => {
265 // We never write out FundingGenerationReady events as, upon disconnection, peers
266 // drop any channels which have not yet exchanged funding_signed.
268 &Event::PaymentReceived { ref payment_hash, ref amt, ref purpose } => {
270 let mut payment_secret = None;
271 let mut user_payment_id = None;
272 let payment_preimage;
274 PaymentPurpose::InvoicePayment { payment_preimage: preimage, payment_secret: secret, user_payment_id: id } => {
275 payment_secret = Some(secret);
276 payment_preimage = *preimage;
277 user_payment_id = Some(id);
279 PaymentPurpose::SpontaneousPayment(preimage) => {
280 payment_preimage = Some(*preimage);
283 write_tlv_fields!(writer, {
284 (0, payment_hash, required),
285 (2, payment_secret, option),
287 (6, user_payment_id, option),
288 (8, payment_preimage, option),
291 &Event::PaymentSent { ref payment_preimage } => {
293 write_tlv_fields!(writer, {
294 (0, payment_preimage, required),
297 &Event::PaymentPathFailed { ref payment_hash, ref rejected_by_dest, ref network_update,
298 ref all_paths_failed, ref path,
306 error_code.write(writer)?;
308 error_data.write(writer)?;
309 write_tlv_fields!(writer, {
310 (0, payment_hash, required),
311 (1, network_update, option),
312 (2, rejected_by_dest, required),
313 (3, all_paths_failed, required),
317 &Event::PendingHTLCsForwardable { time_forwardable: _ } => {
319 // Note that we now ignore these on the read end as we'll re-generate them in
320 // ChannelManager, we write them here only for backwards compatibility.
322 &Event::SpendableOutputs { ref outputs } => {
324 write_tlv_fields!(writer, {
325 (0, VecWriteWrapper(outputs), required),
328 &Event::PaymentForwarded { fee_earned_msat, claim_from_onchain_tx } => {
330 write_tlv_fields!(writer, {
331 (0, fee_earned_msat, option),
332 (2, claim_from_onchain_tx, required),
335 &Event::ChannelClosed { ref channel_id, ref reason } => {
337 write_tlv_fields!(writer, {
338 (0, channel_id, required),
339 (2, reason, required)
342 // Note that, going forward, all new events must only write data inside of
343 // `write_tlv_fields`. Versions 0.0.101+ will ignore odd-numbered events that write
344 // data via `write_tlv_fields`.
349 impl MaybeReadable for Event {
350 fn read<R: io::Read>(reader: &mut R) -> Result<Option<Self>, msgs::DecodeError> {
351 match Readable::read(reader)? {
352 // Note that we do not write a length-prefixed TLV for FundingGenerationReady events,
353 // unlike all other events, thus we return immediately here.
357 let mut payment_hash = PaymentHash([0; 32]);
358 let mut payment_preimage = None;
359 let mut payment_secret = None;
361 let mut user_payment_id = None;
362 read_tlv_fields!(reader, {
363 (0, payment_hash, required),
364 (2, payment_secret, option),
366 (6, user_payment_id, option),
367 (8, payment_preimage, option),
369 let purpose = match payment_secret {
370 Some(secret) => PaymentPurpose::InvoicePayment {
372 payment_secret: secret,
373 user_payment_id: if let Some(id) = user_payment_id {
375 } else { return Err(msgs::DecodeError::InvalidValue) }
377 None if payment_preimage.is_some() => PaymentPurpose::SpontaneousPayment(payment_preimage.unwrap()),
378 None => return Err(msgs::DecodeError::InvalidValue),
380 Ok(Some(Event::PaymentReceived {
390 let mut payment_preimage = PaymentPreimage([0; 32]);
391 read_tlv_fields!(reader, {
392 (0, payment_preimage, required),
394 Ok(Some(Event::PaymentSent {
403 let error_code = Readable::read(reader)?;
405 let error_data = Readable::read(reader)?;
406 let mut payment_hash = PaymentHash([0; 32]);
407 let mut rejected_by_dest = false;
408 let mut network_update = None;
409 let mut all_paths_failed = Some(true);
410 let mut path: Option<Vec<RouteHop>> = Some(vec![]);
411 read_tlv_fields!(reader, {
412 (0, payment_hash, required),
413 (1, network_update, ignorable),
414 (2, rejected_by_dest, required),
415 (3, all_paths_failed, option),
418 Ok(Some(Event::PaymentPathFailed {
422 all_paths_failed: all_paths_failed.unwrap(),
435 let mut outputs = VecReadWrapper(Vec::new());
436 read_tlv_fields!(reader, {
437 (0, outputs, required),
439 Ok(Some(Event::SpendableOutputs { outputs: outputs.0 }))
445 let mut fee_earned_msat = None;
446 let mut claim_from_onchain_tx = false;
447 read_tlv_fields!(reader, {
448 (0, fee_earned_msat, option),
449 (2, claim_from_onchain_tx, required),
451 Ok(Some(Event::PaymentForwarded { fee_earned_msat, claim_from_onchain_tx }))
456 let mut channel_id = [0; 32];
457 let mut reason = None;
458 read_tlv_fields!(reader, {
459 (0, channel_id, required),
460 (2, reason, ignorable),
462 if reason.is_none() { return Ok(None); }
463 Ok(Some(Event::ChannelClosed { channel_id, reason: reason.unwrap() }))
465 // Versions prior to 0.0.100 did not ignore odd types, instead returning InvalidValue.
466 // Version 0.0.100 failed to properly ignore odd types, possibly resulting in corrupt
469 // If the event is of unknown type, assume it was written with `write_tlv_fields`,
470 // which prefixes the whole thing with a length BigSize. Because the event is
471 // odd-type unknown, we should treat it as `Ok(None)` even if it has some TLV
472 // fields that are even. Thus, we avoid using `read_tlv_fields` and simply read
473 // exactly the number of bytes specified, ignoring them entirely.
474 let tlv_len: BigSize = Readable::read(reader)?;
475 FixedLengthReader::new(reader, tlv_len.0)
476 .eat_remaining().map_err(|_| msgs::DecodeError::ShortRead)?;
479 _ => Err(msgs::DecodeError::InvalidValue)
484 /// An event generated by ChannelManager which indicates a message should be sent to a peer (or
485 /// broadcast to most peers).
486 /// These events are handled by PeerManager::process_events if you are using a PeerManager.
487 #[derive(Clone, Debug)]
488 pub enum MessageSendEvent {
489 /// Used to indicate that we've accepted a channel open and should send the accept_channel
490 /// message provided to the given peer.
492 /// The node_id of the node which should receive this message
494 /// The message which should be sent.
495 msg: msgs::AcceptChannel,
497 /// Used to indicate that we've initiated a channel open and should send the open_channel
498 /// message provided to the given peer.
500 /// The node_id of the node which should receive this message
502 /// The message which should be sent.
503 msg: msgs::OpenChannel,
505 /// Used to indicate that a funding_created message should be sent to the peer with the given node_id.
507 /// The node_id of the node which should receive this message
509 /// The message which should be sent.
510 msg: msgs::FundingCreated,
512 /// Used to indicate that a funding_signed message should be sent to the peer with the given node_id.
514 /// The node_id of the node which should receive this message
516 /// The message which should be sent.
517 msg: msgs::FundingSigned,
519 /// Used to indicate that a funding_locked message should be sent to the peer with the given node_id.
521 /// The node_id of the node which should receive these message(s)
523 /// The funding_locked message which should be sent.
524 msg: msgs::FundingLocked,
526 /// Used to indicate that an announcement_signatures message should be sent to the peer with the given node_id.
527 SendAnnouncementSignatures {
528 /// The node_id of the node which should receive these message(s)
530 /// The announcement_signatures message which should be sent.
531 msg: msgs::AnnouncementSignatures,
533 /// Used to indicate that a series of HTLC update messages, as well as a commitment_signed
534 /// message should be sent to the peer with the given node_id.
536 /// The node_id of the node which should receive these message(s)
538 /// The update messages which should be sent. ALL messages in the struct should be sent!
539 updates: msgs::CommitmentUpdate,
541 /// Used to indicate that a revoke_and_ack message should be sent to the peer with the given node_id.
543 /// The node_id of the node which should receive this message
545 /// The message which should be sent.
546 msg: msgs::RevokeAndACK,
548 /// Used to indicate that a closing_signed message should be sent to the peer with the given node_id.
550 /// The node_id of the node which should receive this message
552 /// The message which should be sent.
553 msg: msgs::ClosingSigned,
555 /// Used to indicate that a shutdown message should be sent to the peer with the given node_id.
557 /// The node_id of the node which should receive this message
559 /// The message which should be sent.
562 /// Used to indicate that a channel_reestablish message should be sent to the peer with the given node_id.
563 SendChannelReestablish {
564 /// The node_id of the node which should receive this message
566 /// The message which should be sent.
567 msg: msgs::ChannelReestablish,
569 /// Used to indicate that a channel_announcement and channel_update should be broadcast to all
570 /// peers (except the peer with node_id either msg.contents.node_id_1 or msg.contents.node_id_2).
572 /// Note that after doing so, you very likely (unless you did so very recently) want to call
573 /// ChannelManager::broadcast_node_announcement to trigger a BroadcastNodeAnnouncement event.
574 /// This ensures that any nodes which see our channel_announcement also have a relevant
575 /// node_announcement, including relevant feature flags which may be important for routing
576 /// through or to us.
577 BroadcastChannelAnnouncement {
578 /// The channel_announcement which should be sent.
579 msg: msgs::ChannelAnnouncement,
580 /// The followup channel_update which should be sent.
581 update_msg: msgs::ChannelUpdate,
583 /// Used to indicate that a node_announcement should be broadcast to all peers.
584 BroadcastNodeAnnouncement {
585 /// The node_announcement which should be sent.
586 msg: msgs::NodeAnnouncement,
588 /// Used to indicate that a channel_update should be broadcast to all peers.
589 BroadcastChannelUpdate {
590 /// The channel_update which should be sent.
591 msg: msgs::ChannelUpdate,
593 /// Used to indicate that a channel_update should be sent to a single peer.
594 /// In contrast to [`Self::BroadcastChannelUpdate`], this is used when the channel is a
595 /// private channel and we shouldn't be informing all of our peers of channel parameters.
597 /// The node_id of the node which should receive this message
599 /// The channel_update which should be sent.
600 msg: msgs::ChannelUpdate,
602 /// Broadcast an error downstream to be handled
604 /// The node_id of the node which should receive this message
606 /// The action which should be taken.
607 action: msgs::ErrorAction
609 /// Query a peer for channels with funding transaction UTXOs in a block range.
610 SendChannelRangeQuery {
611 /// The node_id of this message recipient
613 /// The query_channel_range which should be sent.
614 msg: msgs::QueryChannelRange,
616 /// Request routing gossip messages from a peer for a list of channels identified by
617 /// their short_channel_ids.
619 /// The node_id of this message recipient
621 /// The query_short_channel_ids which should be sent.
622 msg: msgs::QueryShortChannelIds,
624 /// Sends a reply to a channel range query. This may be one of several SendReplyChannelRange events
625 /// emitted during processing of the query.
626 SendReplyChannelRange {
627 /// The node_id of this message recipient
629 /// The reply_channel_range which should be sent.
630 msg: msgs::ReplyChannelRange,
634 /// A trait indicating an object may generate message send events
635 pub trait MessageSendEventsProvider {
636 /// Gets the list of pending events which were generated by previous actions, clearing the list
638 fn get_and_clear_pending_msg_events(&self) -> Vec<MessageSendEvent>;
641 /// A trait indicating an object may generate events.
643 /// Events are processed by passing an [`EventHandler`] to [`process_pending_events`].
647 /// See [`process_pending_events`] for requirements around event processing.
649 /// When using this trait, [`process_pending_events`] will call [`handle_event`] for each pending
650 /// event since the last invocation. The handler must either act upon the event immediately
651 /// or preserve it for later handling.
653 /// Note, handlers may call back into the provider and thus deadlocking must be avoided. Be sure to
654 /// consult the provider's documentation on the implication of processing events and how a handler
655 /// may safely use the provider (e.g., see [`ChannelManager::process_pending_events`] and
656 /// [`ChainMonitor::process_pending_events`]).
658 /// (C-not implementable) As there is likely no reason for a user to implement this trait on their
661 /// [`process_pending_events`]: Self::process_pending_events
662 /// [`handle_event`]: EventHandler::handle_event
663 /// [`ChannelManager::process_pending_events`]: crate::ln::channelmanager::ChannelManager#method.process_pending_events
664 /// [`ChainMonitor::process_pending_events`]: crate::chain::chainmonitor::ChainMonitor#method.process_pending_events
665 pub trait EventsProvider {
666 /// Processes any events generated since the last call using the given event handler.
668 /// Subsequent calls must only process new events. However, handlers must be capable of handling
669 /// duplicate events across process restarts. This may occur if the provider was recovered from
670 /// an old state (i.e., it hadn't been successfully persisted after processing pending events).
671 fn process_pending_events<H: Deref>(&self, handler: H) where H::Target: EventHandler;
674 /// A trait implemented for objects handling events from [`EventsProvider`].
675 pub trait EventHandler {
676 /// Handles the given [`Event`].
678 /// See [`EventsProvider`] for details that must be considered when implementing this method.
679 fn handle_event(&self, event: &Event);
682 impl<F> EventHandler for F where F: Fn(&Event) {
683 fn handle_event(&self, event: &Event) {