From fc5f8e32f58be3911039bda4da4f182e9f723e00 Mon Sep 17 00:00:00 2001 From: yyforyongyu Date: Mon, 4 Nov 2024 11:48:33 +0800 Subject: [PATCH] chanfitness: exit early when there are no updates --- channeldb/peers.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/channeldb/peers.go b/channeldb/peers.go index 62342fc79..ed36c51df 100644 --- a/channeldb/peers.go +++ b/channeldb/peers.go @@ -50,6 +50,12 @@ type FlapCount struct { // bucket for the peer's pubkey if necessary. Note that this function overwrites // the current value. func (d *DB) WriteFlapCounts(flapCounts map[route.Vertex]*FlapCount) error { + // Exit early if there are no updates. + if len(flapCounts) == 0 { + log.Debugf("No flap counts to write, skipped db update") + return nil + } + return kvdb.Update(d, func(tx kvdb.RwTx) error { // Run through our set of flap counts and record them for // each peer, creating a bucket for the peer pubkey if required.