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:
7 files changed
+254
-86
No files matched your search
+2
-2
@@ -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