From 7c4058bd472d6ef80b0eaea420de806d5de24e77 Mon Sep 17 00:00:00 2001 From: Domino Valdano <2644901+reductionista@users.noreply.github.com> Date: Wed, 15 Jan 2025 12:29:57 -0800 Subject: [PATCH] Remove ILogPoller interface, add LogPoller interface to chain.go Also: add GetBlockWithOpts to MultiClient --- pkg/solana/chain.go | 13 ++++++++++--- pkg/solana/client/multi_client.go | 9 +++++++++ pkg/solana/logpoller/log_poller.go | 10 +--------- 3 files changed, 20 insertions(+), 12 deletions(-) diff --git a/pkg/solana/chain.go b/pkg/solana/chain.go index 60ac30755..a49e218f8 100644 --- a/pkg/solana/chain.go +++ b/pkg/solana/chain.go @@ -34,12 +34,19 @@ import ( txmutils "github.com/smartcontractkit/chainlink-solana/pkg/solana/txm/utils" ) +type LogPoller interface { + Start(context.Context) error + Close() error + RegisterFilter(ctx context.Context, filter logpoller.Filter) error + UnregisterFilter(ctx context.Context, name string) error +} + type Chain interface { types.ChainService ID() string Config() config.Config - LogPoller() logpoller.ILogPoller + LogPoller() LogPoller TxManager() TxManager // Reader returns a new Reader from the available list of nodes (if there are multiple, it will randomly select one) Reader() (client.Reader, error) @@ -92,7 +99,7 @@ type chain struct { services.StateMachine id string cfg *config.TOMLConfig - lp logpoller.ILogPoller + lp logpoller.LogPoller txm *txm.Txm balanceMonitor services.Service lggr logger.Logger @@ -407,7 +414,7 @@ func (c *chain) Config() config.Config { return c.cfg } -func (c *chain) LogPoller() logpoller.ILogPoller { +func (c *chain) LogPoller() LogPoller { return c.lp } diff --git a/pkg/solana/client/multi_client.go b/pkg/solana/client/multi_client.go index eb159e114..c55e2c9b9 100644 --- a/pkg/solana/client/multi_client.go +++ b/pkg/solana/client/multi_client.go @@ -166,3 +166,12 @@ func (m *MultiClient) GetSignaturesForAddressWithOpts(ctx context.Context, addr return r.GetSignaturesForAddressWithOpts(ctx, addr, opts) } + +func (m *MultiClient) GetBlockWithOpts(ctx context.Context, slot uint64, opts *rpc.GetBlockOpts) (*rpc.GetBlockResult, error) { + r, err := m.getClient() + if err != nil { + return nil, err + } + + return r.GetBlockWithOpts(ctx, slot, opts) +} diff --git a/pkg/solana/logpoller/log_poller.go b/pkg/solana/logpoller/log_poller.go index dee9be886..ec454d20a 100644 --- a/pkg/solana/logpoller/log_poller.go +++ b/pkg/solana/logpoller/log_poller.go @@ -32,14 +32,6 @@ type ORM interface { SelectSeqNums(ctx context.Context) (map[int64]int64, error) } -type ILogPoller interface { - Start(context.Context) error - Close() error - RegisterFilter(ctx context.Context, filter Filter) error - UnregisterFilter(ctx context.Context, name string) error - Process(programEvent ProgramEvent) error -} - type LogPoller struct { services.Service eng *services.Engine @@ -53,7 +45,7 @@ type LogPoller struct { filters *filters } -func New(lggr logger.SugaredLogger, orm ORM, cl internal.Loader[client.Reader]) ILogPoller { +func New(lggr logger.SugaredLogger, orm ORM, cl internal.Loader[client.Reader]) *LogPoller { lggr = logger.Sugared(logger.Named(lggr, "LogPoller")) lp := &LogPoller{ orm: orm,