Skip to content

Commit

Permalink
Remove ILogPoller interface, add LogPoller interface to chain.go
Browse files Browse the repository at this point in the history
Also: add GetBlockWithOpts to MultiClient
  • Loading branch information
reductionista committed Jan 15, 2025
1 parent 1395dd3 commit 7c4058b
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 12 deletions.
13 changes: 10 additions & 3 deletions pkg/solana/chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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

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

View workflow job for this annotation

GitHub Actions / Relay Run Unit Tests

cannot use c.lp (variable of type logpoller.LogPoller) as LogPoller value in return statement: logpoller.LogPoller does not implement LogPoller (method RegisterFilter has pointer receiver)
}

Expand Down
9 changes: 9 additions & 0 deletions pkg/solana/client/multi_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
10 changes: 1 addition & 9 deletions pkg/solana/logpoller/log_poller.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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,
Expand Down

0 comments on commit 7c4058b

Please sign in to comment.