htlcswitch: add new ticker in switch to batch log forwarding events

In this commit, we extend the switch as is, to record details
concerning settled payment circuits. To do this, we introduce a new
interface to the package: the ForwardingLog. This is a tiny interface
that simply lets us abstract away the details of the storage backing of
the forwarding log.

Each time we receive a successful HTLC settle, we’ll log the full
details (chans, fees, time) as a pending forwarding log entry. Every 15
seconds, we’ll then batch flush out these entries to disk. When we’re
exiting, we’ll try to flush out all entries to ensure everything gets
recorded to disk.
This commit is contained in:
Olaoluwa Osuntokun committed 2018-03-06 13:56:11 -05:00
1 parent 6f11fee1a4
commit ad522a72c1
3 files changed
+130 -9

No files matched your search

+12
View File
@@ -121,3 +121,15 @@ type Peer interface {
// properly handle.
Disconnect(reason error)
}
// ForwardingLog is an interface that represents a time series database which
// keep track of all successfully completed payment circuits. Every few
// seconds, the switch will collate and flush out all the successful payment
// circuits during the last interval.
type ForwardingLog interface {
// AddForwardingEvents is a method that should write out the set of
// forwarding events in a batch to persistent storage. Outside
// sub-systems can then query the contents of the log for analysis,
// visualizations, etc.
AddForwardingEvents([]channeldb.ForwardingEvent) error
}