mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-11-10 14:17:56 +01:00
graph/db: convert ChanUpdatesInHorizon to use iterators
In this commit, we refactor the ChanUpdatesInHorizon method to return an iterator instead of a slice. This change significantly reduces memory usage when dealing with large result sets by allowing callers to process items incrementally rather than loading everything into memory at once.
This commit is contained in:
@@ -593,13 +593,13 @@ func (b *Builder) pruneZombieChans() error {
|
||||
|
||||
startTime := time.Unix(0, 0)
|
||||
endTime := time.Now().Add(-1 * chanExpiry)
|
||||
oldEdges, err := b.cfg.Graph.ChanUpdatesInHorizon(startTime, endTime)
|
||||
oldEdgesIter, err := b.cfg.Graph.ChanUpdatesInHorizon(startTime, endTime)
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to fetch expired channel updates "+
|
||||
"chans: %v", err)
|
||||
}
|
||||
|
||||
for _, u := range oldEdges {
|
||||
for u := range oldEdgesIter {
|
||||
err = filterPruneChans(u.Info, u.Policy1, u.Policy2)
|
||||
if err != nil {
|
||||
return fmt.Errorf("error filtering channels to "+
|
||||
|
||||
Reference in New Issue
Block a user