htlcswitch: add final htlc event to notifier

This commit is contained in:
Joost Jager committed 2022-10-27 16:42:36 +02:00
1 parent 28256b7ea8
commit 511fb00777
21 files changed
+729 -404

No files matched your search

+33
View File
@@ -294,6 +294,18 @@ type SettleEvent struct {
Timestamp time.Time
}
type FinalHtlcEvent struct {
CircuitKey
Settled bool
// Offchain is indicating whether the htlc was resolved off-chain.
Offchain bool
// Timestamp is the time when this htlc was settled.
Timestamp time.Time
}
// NotifyForwardingEvent notifies the HtlcNotifier than a htlc has been
// forwarded.
//
@@ -382,6 +394,27 @@ func (h *HtlcNotifier) NotifySettleEvent(key HtlcKey,
}
}
// NotifyFinalHtlcEvent notifies the HtlcNotifier that the final outcome for an
// htlc has been determined.
//
// Note this is part of the htlcNotifier interface.
func (h *HtlcNotifier) NotifyFinalHtlcEvent(key channeldb.CircuitKey,
info channeldb.FinalHtlcInfo) {
event := &FinalHtlcEvent{
CircuitKey: key,
Settled: info.Settled,
Offchain: info.Offchain,
Timestamp: h.now(),
}
log.Tracef("Notifying final settle event: %v", key)
if err := h.ntfnServer.SendUpdate(event); err != nil {
log.Warnf("Unable to send settle event: %v", err)
}
}
// newHtlc key returns a htlc key for the packet provided. If the packet
// has a zero incoming channel ID, the packet is for one of our own sends,
// which has the payment id stashed in the incoming htlc id. If this is the