From 5bb5b6a260c0797fb39a8588735ccb18aed697d0 Mon Sep 17 00:00:00 2001 From: Elle Mouton Date: Tue, 24 Jun 2025 12:15:27 +0200 Subject: [PATCH] graph/db: fix log line in KVStore Ensure that the log line in `ChanUpdatesInHorizon` cannot cause a divide-by-zero panic. --- graph/db/kv_store.go | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/graph/db/kv_store.go b/graph/db/kv_store.go index 62dda158d..c2c681965 100644 --- a/graph/db/kv_store.go +++ b/graph/db/kv_store.go @@ -2149,9 +2149,14 @@ func (c *KVStore) ChanUpdatesInHorizon(startTime, c.chanCache.insert(chanid, channel) } - log.Debugf("ChanUpdatesInHorizon hit percentage: %f (%d/%d)", - float64(hits)/float64(len(edgesInHorizon)), hits, - len(edgesInHorizon)) + if len(edgesInHorizon) > 0 { + log.Debugf("ChanUpdatesInHorizon hit percentage: %f (%d/%d)", + float64(hits)/float64(len(edgesInHorizon)), hits, + len(edgesInHorizon)) + } else { + log.Debugf("ChanUpdatesInHorizon returned no edges in "+ + "horizon (%s, %s)", startTime, endTime) + } return edgesInHorizon, nil }