Skip to content

Commit

Permalink
lnd: make sure forward sync stops when synced
Browse files Browse the repository at this point in the history
  • Loading branch information
JssDWt committed Apr 9, 2024
1 parent e7a097a commit a76fcc8
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion lnd/forwards_sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ func NewForwardSync(

var forwardChannelSyncInterval time.Duration = time.Minute * 5

const maxEvents = 10_000

func (s *ForwardSync) ForwardsSynchronize(ctx context.Context) {
s.forwardsSynchronizeOnce(ctx)

Expand Down Expand Up @@ -60,7 +62,7 @@ func (s *ForwardSync) forwardsSynchronizeOnce(ctx context.Context) {
for {
forwardHistory, err := s.client.client.ForwardingHistory(context.Background(), &lnrpc.ForwardingHistoryRequest{
StartTime: startTime / 1_000_000_000,
NumMaxEvents: 10000,
NumMaxEvents: maxEvents,
})
if err != nil {
log.Printf("forwardsSynchronizeOnce(%x) - ForwardingHistory error: %v", s.nodeid, err)
Expand Down Expand Up @@ -89,5 +91,9 @@ func (s *ForwardSync) forwardsSynchronizeOnce(ctx context.Context) {
log.Printf("forwardsSynchronizeOnce(%x) - store.InsertForwards() error: %v", s.nodeid, err)
return
}

if len(forwardHistory.ForwardingEvents) < maxEvents {
break
}
}
}

0 comments on commit a76fcc8

Please sign in to comment.