Skip to content

Commit 5bb5b6a

Browse files
committed
graph/db: fix log line in KVStore
Ensure that the log line in `ChanUpdatesInHorizon` cannot cause a divide-by-zero panic.
1 parent 39e521e commit 5bb5b6a

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

graph/db/kv_store.go

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2149,9 +2149,14 @@ func (c *KVStore) ChanUpdatesInHorizon(startTime,
21492149
c.chanCache.insert(chanid, channel)
21502150
}
21512151

2152-
log.Debugf("ChanUpdatesInHorizon hit percentage: %f (%d/%d)",
2153-
float64(hits)/float64(len(edgesInHorizon)), hits,
2154-
len(edgesInHorizon))
2152+
if len(edgesInHorizon) > 0 {
2153+
log.Debugf("ChanUpdatesInHorizon hit percentage: %f (%d/%d)",
2154+
float64(hits)/float64(len(edgesInHorizon)), hits,
2155+
len(edgesInHorizon))
2156+
} else {
2157+
log.Debugf("ChanUpdatesInHorizon returned no edges in "+
2158+
"horizon (%s, %s)", startTime, endTime)
2159+
}
21552160

21562161
return edgesInHorizon, nil
21572162
}

0 commit comments

Comments
 (0)