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:
3 files changed
+130
-9
No files matched your search
@@ -80,6 +80,22 @@ func (m *mockFeeEstimator) Stop() error {
|
||||
|
||||
var _ lnwallet.FeeEstimator = (*mockFeeEstimator)(nil)
|
||||
|
||||
type mockForwardingLog struct {
|
||||
sync.Mutex
|
||||
events map[time.Time]channeldb.ForwardingEvent
|
||||
}
|
||||
|
||||
func (m *mockForwardingLog) AddForwardingEvents(events []channeldb.ForwardingEvent) error {
|
||||
m.Lock()
|
||||
defer m.Unlock()
|
||||
|
||||
for _, event := range events {
|
||||
m.events[event.Timestamp] = event
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
type mockServer struct {
|
||||
started int32
|
||||
shutdown int32
|
||||
|
||||
Reference in new issue
Block a user