Skip to content

Commit

Permalink
bump go 1.23; implement one iter.Seq
Browse files Browse the repository at this point in the history
  • Loading branch information
jmank88 committed Sep 5, 2024
1 parent adb3c95 commit bfcd6c0
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 18 deletions.
4 changes: 3 additions & 1 deletion core/scripts/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
module github.com/smartcontractkit/chainlink/core/scripts

go 1.22.5
go 1.23

toolchain go1.23.0

// Make sure we're working with the latest chainlink libs
replace github.com/smartcontractkit/chainlink/v2 => ../../
Expand Down
12 changes: 7 additions & 5 deletions core/services/relay/evm/bindings.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package evm
import (
"context"
"fmt"
"iter"

commontypes "github.com/smartcontractkit/chainlink-common/pkg/types"
"github.com/smartcontractkit/chainlink/v2/core/chains/evm/logpoller"
Expand Down Expand Up @@ -110,11 +111,12 @@ func (b bindings) BatchGetLatestValues(ctx context.Context, request commontypes.
return batchGetLatestValuesResults, err
}

func (b bindings) ForEach(ctx context.Context, fn func(context.Context, *contractBinding) error) error {
for _, cb := range b.contractBindings {
if err := fn(ctx, cb); err != nil {
return err
func (b bindings) All() iter.Seq[*contractBinding] {
return func(yield func(*contractBinding) bool) {
for _, cb := range b.contractBindings {
if !yield(cb) {
return
}
}
}
return nil
}
23 changes: 14 additions & 9 deletions core/services/relay/evm/chain_reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,11 @@ func NewChainReaderService(ctx context.Context, lggr logger.Logger, lp logpoller
DefaultMaxParallelRpcCalls,
)

err = cr.bindings.ForEach(ctx, func(c context.Context, cb *contractBinding) error {
for cb := range cr.bindings.All() {
for _, rb := range cb.readBindings {
rb.SetCodec(cr.codec)
}
return nil
})
}

return cr, err
}
Expand Down Expand Up @@ -142,14 +141,17 @@ func (cr *chainReader) Name() string { return cr.lggr.Name() }
// Start registers polling filters if contracts are already bound.
func (cr *chainReader) Start(ctx context.Context) error {
return cr.StartOnce("ChainReader", func() error {
return cr.bindings.ForEach(ctx, func(c context.Context, cb *contractBinding) error {
for cb := range cr.bindings.All() {
for _, rb := range cb.readBindings {
if err := rb.Register(ctx); err != nil {
return err
}
}
return cb.Register(ctx, cr.lp)
})
if err := cb.Register(ctx, cr.lp); err != nil {
return err
}
}
return nil
})
}

Expand All @@ -158,14 +160,17 @@ func (cr *chainReader) Close() error {
return cr.StopOnce("ChainReader", func() error {
ctx, cancel := context.WithTimeout(context.Background(), time.Second)
defer cancel()
return cr.bindings.ForEach(ctx, func(c context.Context, cb *contractBinding) error {
for cb := range cr.bindings.All() {
for _, rb := range cb.readBindings {
if err := rb.Unregister(ctx); err != nil {
return err
}
}
return cb.Unregister(ctx, cr.lp)
})
if err := cb.Unregister(ctx, cr.lp); err != nil {
return err
}
}
return nil
})
}

Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/smartcontractkit/chainlink/v2

go 1.22.5
go 1.23

require (
github.com/Depado/ginprom v1.8.0
Expand Down
4 changes: 3 additions & 1 deletion integration-tests/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
module github.com/smartcontractkit/chainlink/integration-tests

go 1.22.5
go 1.23

toolchain go1.23.0

// Make sure we're working with the latest chainlink libs
replace github.com/smartcontractkit/chainlink/v2 => ../
Expand Down
4 changes: 3 additions & 1 deletion integration-tests/load/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
module github.com/smartcontractkit/chainlink/load-tests

go 1.22.5
go 1.23

toolchain go1.23.0

// Make sure we're working with the latest chainlink libs
replace github.com/smartcontractkit/chainlink/v2 => ../../
Expand Down

0 comments on commit bfcd6c0

Please sign in to comment.