multi: let ForEachNodeChannel take a reset param

This commit is contained in:
Elle Mouton
2025-07-11 10:31:29 +02:00
parent 16126d7703
commit e5fbca8299
13 changed files with 57 additions and 43 deletions

View File

@@ -42,7 +42,7 @@ type Manager struct {
// channels. The ChannelEdgePolicy parameter may be nil.
ForAllOutgoingChannels func(ctx context.Context,
cb func(*models.ChannelEdgeInfo,
*models.ChannelEdgePolicy) error) error
*models.ChannelEdgePolicy) error, reset func()) error
// FetchChannel is used to query local channel parameters. Optionally an
// existing db tx can be supplied.
@@ -152,7 +152,14 @@ func (r *Manager) UpdatePolicy(ctx context.Context,
// Next, we'll loop over all the outgoing channels the router knows of.
// If we have a filter then we'll only collect those channels, otherwise
// we'll collect them all.
err := r.ForAllOutgoingChannels(ctx, processChan)
err := r.ForAllOutgoingChannels(
ctx, processChan,
func() {
failedUpdates = nil
edgesToUpdate = nil
clear(policiesToUpdate)
},
)
if err != nil {
return nil, err
}

View File

@@ -125,7 +125,7 @@ func TestManager(t *testing.T) {
forAllOutgoingChannels := func(_ context.Context,
cb func(*models.ChannelEdgeInfo,
*models.ChannelEdgePolicy) error) error {
*models.ChannelEdgePolicy) error, _ func()) error {
for _, c := range channelSet {
if err := cb(c.edgeInfo, &currentPolicy); err != nil {