Skip to content

Commit fc5f8e3

Browse files
committed
chanfitness: exit early when there are no updates
1 parent 523ecc0 commit fc5f8e3

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

channeldb/peers.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,12 @@ type FlapCount struct {
5050
// bucket for the peer's pubkey if necessary. Note that this function overwrites
5151
// the current value.
5252
func (d *DB) WriteFlapCounts(flapCounts map[route.Vertex]*FlapCount) error {
53+
// Exit early if there are no updates.
54+
if len(flapCounts) == 0 {
55+
log.Debugf("No flap counts to write, skipped db update")
56+
return nil
57+
}
58+
5359
return kvdb.Update(d, func(tx kvdb.RwTx) error {
5460
// Run through our set of flap counts and record them for
5561
// each peer, creating a bucket for the peer pubkey if required.

0 commit comments

Comments
 (0)