Skip to content

Commit 36eb0e3

Browse files
committed
graph/db: use batch loading for NodeUpdatesInHorizon
1 parent c8c8671 commit 36eb0e3

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

graph/db/sql_store.go

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -554,14 +554,16 @@ func (s *SQLStore) NodeUpdatesInHorizon(startTime,
554554
return fmt.Errorf("unable to fetch nodes: %w", err)
555555
}
556556

557-
for _, dbNode := range dbNodes {
558-
node, err := buildNode(ctx, db, &dbNode)
559-
if err != nil {
560-
return fmt.Errorf("unable to build node: %w",
561-
err)
562-
}
557+
err = forEachNodeInBatch(
558+
ctx, s.cfg.PaginationCfg, db, dbNodes,
559+
func(_ int64, node *models.LightningNode) error {
560+
nodes = append(nodes, *node)
563561

564-
nodes = append(nodes, *node)
562+
return nil
563+
},
564+
)
565+
if err != nil {
566+
return fmt.Errorf("unable to build nodes: %w", err)
565567
}
566568

567569
return nil

0 commit comments

Comments
 (0)