Skip to content

Commit

Permalink
Use ch.multiClient instead of lazy-loader
Browse files Browse the repository at this point in the history
  • Loading branch information
reductionista committed Jan 16, 2025
1 parent e84fbe5 commit 82fa8cc
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 17 deletions.
5 changes: 3 additions & 2 deletions pkg/solana/chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,8 @@ func NewChain(cfg *config.TOMLConfig, opts ChainOpts) (Chain, error) {
var _ Chain = (*chain)(nil)

type chain struct {
services.StateMachine
services.Service
engine *services.Engine
id string
cfg *config.TOMLConfig
lp logpoller.LogPoller
Expand Down Expand Up @@ -324,7 +325,7 @@ func newChain(id string, cfg *config.TOMLConfig, ks core.Keystore, lggr logger.L
}

// TODO: import typeProvider function from codec package and pass to constructor
ch.lp = logpoller.New(logger.Sugared(logger.Named(lggr, "LogPoller")), logpoller.NewORM(ch.ID(), ds, lggr), lc)
ch.lp = logpoller.New(logger.Sugared(logger.Named(lggr, "LogPoller")), logpoller.NewORM(ch.ID(), ds, lggr), ch.multiClient)

Check failure on line 328 in pkg/solana/chain.go

View workflow job for this annotation

GitHub Actions / Relay Run Unit Tests

cannot use logpoller.New(logger.Sugared(logger.Named(lggr, "LogPoller")), logpoller.NewORM(ch.ID(), ds, lggr), ch.multiClient) (value of type *logpoller.LogPoller) as logpoller.LogPoller value in assignment
ch.txm = txm.NewTxm(ch.id, tc, sendTx, cfg, ks, lggr)
ch.balanceMonitor = monitor.NewBalanceMonitor(ch.id, cfg, lggr, ks, bc)
return &ch, nil
Expand Down
14 changes: 3 additions & 11 deletions pkg/solana/logpoller/log_poller.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import (
"github.com/smartcontractkit/chainlink-common/pkg/utils"

"github.com/smartcontractkit/chainlink-solana/pkg/solana/client"
"github.com/smartcontractkit/chainlink-solana/pkg/solana/internal"
)

var (
Expand All @@ -35,17 +34,16 @@ type ORM interface {
type LogPoller struct {
services.Service
eng *services.Engine
services.StateMachine

lggr logger.SugaredLogger
orm ORM
client internal.Loader[client.Reader]
client client.Reader
collector *EncodedLogCollector

filters *filters
}

func New(lggr logger.SugaredLogger, orm ORM, cl internal.Loader[client.Reader]) *LogPoller {
func New(lggr logger.SugaredLogger, orm ORM, cl client.Reader) *LogPoller {
lggr = logger.Sugared(logger.Named(lggr, "LogPoller"))
lp := &LogPoller{
orm: orm,
Expand All @@ -62,13 +60,7 @@ func New(lggr logger.SugaredLogger, orm ORM, cl internal.Loader[client.Reader])
return lp
}

func (lp *LogPoller) start(context.Context) error {
cl, err := lp.client.Get()
if err != nil {
return err
}
lp.collector = NewEncodedLogCollector(cl, lp, lp.lggr)

func (lp *LogPoller) start(_ context.Context) error {
lp.eng.Go(lp.run)
lp.eng.Go(lp.backgroundWorkerRun)
return nil
Expand Down
5 changes: 1 addition & 4 deletions pkg/solana/logpoller/log_poller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,11 @@ import (
"github.com/gagliardetto/solana-go"
"github.com/google/uuid"
"github.com/smartcontractkit/chainlink-common/pkg/logger"
commonutils "github.com/smartcontractkit/chainlink-common/pkg/utils"
"github.com/smartcontractkit/chainlink-common/pkg/utils/tests"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/mock"
"github.com/stretchr/testify/require"

"github.com/smartcontractkit/chainlink-solana/pkg/solana/client"
clientmocks "github.com/smartcontractkit/chainlink-solana/pkg/solana/client/mocks"
"github.com/smartcontractkit/chainlink-solana/pkg/solana/codec"
)
Expand Down Expand Up @@ -69,9 +67,8 @@ func TestProcess(t *testing.T) {

orm := newMockORM(t)
cl := clientmocks.NewReaderWriter(t)
loader := commonutils.NewLazyLoad(func() (client.Reader, error) { return cl, nil })
lggr := logger.Sugared(logger.Test(t))
lp := New(lggr, orm, loader)
lp := New(lggr, orm, cl)

var idlTypeInt64 codec.IdlType
var idlTypeString codec.IdlType
Expand Down

0 comments on commit 82fa8cc

Please sign in to comment.