Skip to content

Commit

Permalink
address feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
EasterTheBunny committed Feb 3, 2025
1 parent 06683c1 commit 0894ae5
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 15 deletions.
2 changes: 2 additions & 0 deletions pkg/solana/chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"github.com/smartcontractkit/chainlink-common/pkg/sqlutil"
"github.com/smartcontractkit/chainlink-common/pkg/types"
"github.com/smartcontractkit/chainlink-common/pkg/types/core"
"github.com/smartcontractkit/chainlink-common/pkg/types/query"
"github.com/smartcontractkit/chainlink-common/pkg/utils"
mn "github.com/smartcontractkit/chainlink-framework/multinode"

Expand All @@ -41,6 +42,7 @@ type LogPoller interface {
Close() error
RegisterFilter(ctx context.Context, filter logpoller.Filter) error
UnregisterFilter(ctx context.Context, name string) error
FilteredLogs(context.Context, []query.Expression, query.LimitAndSort, string) ([]logpoller.Log, error)
}

type Chain interface {
Expand Down
16 changes: 8 additions & 8 deletions pkg/solana/chainreader/event_read_binding.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,22 +28,22 @@ type eventReadBinding struct {
modifier commoncodec.Modifier
key solana.PublicKey
remapper remapHelper
indexedSubkeys map[string]subkeyTuple
events EventsReader
indexedSubKeys map[string]subkeyTuple
reader EventsReader
eventSig [logpoller.EventSignatureLength]byte
}

func newEventReadBinding(
namespace, genericName string,
indexedSubkeys map[string]subkeyTuple,
events EventsReader,
indexedSubKeys map[string]subkeyTuple,
reader EventsReader,
eventSig [logpoller.EventSignatureLength]byte,
) *eventReadBinding {
binding := &eventReadBinding{
namespace: namespace,
genericName: genericName,
indexedSubkeys: indexedSubkeys,
events: events,
indexedSubKeys: indexedSubKeys,
reader: reader,
eventSig: eventSig,
}

Expand Down Expand Up @@ -107,7 +107,7 @@ func (b *eventReadBinding) QueryKey(

itemType := strings.Join([]string{b.namespace, b.genericName}, ".")

logs, err := b.events.FilteredLogs(ctx, filter.Expressions, limitAndSort, itemType)
logs, err := b.reader.FilteredLogs(ctx, filter.Expressions, limitAndSort, itemType)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -140,7 +140,7 @@ func (b *eventReadBinding) remapPrimitive(expression query.Expression) (query.Ex
}

func (b *eventReadBinding) encodeComparator(comparator *primitives.Comparator) (query.Expression, error) {
onChainTuple, ok := b.indexedSubkeys[comparator.Name]
onChainTuple, ok := b.indexedSubKeys[comparator.Name]
if !ok {
return query.Expression{}, fmt.Errorf("%w: unknown indexed subkey mapping %s", types.ErrInvalidConfig, comparator.Name)
}
Expand Down
5 changes: 2 additions & 3 deletions pkg/solana/config/chain_reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,8 @@ func (r ReadType) String() string {
}

type IndexedField struct {
OffChainPath string `json:"offChainPath"`
OnChainPath string `json:"onChainPath"`
IndexPosition int `json:"-"`
OffChainPath string `json:"offChainPath"`
OnChainPath string `json:"onChainPath"`
}

func (c *ChainContractReader) UnmarshalJSON(bytes []byte) error {
Expand Down
5 changes: 1 addition & 4 deletions pkg/solana/relay.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,10 +162,7 @@ func (r *Relayer) NewContractReader(_ context.Context, chainReaderConfig []byte)
return nil, fmt.Errorf("failed to init account reader err: %s", err)
}

// TODO: create a logpoller
var logpoller chainreader.EventsReader

return chainreader.NewContractReaderService(r.lggr, &chainreader.RPCClientWrapper{AccountReader: accountReader}, cfg, logpoller)
return chainreader.NewContractReaderService(r.lggr, &chainreader.RPCClientWrapper{AccountReader: accountReader}, cfg, r.chain.LogPoller())
}

func (r *Relayer) NewMedianProvider(ctx context.Context, rargs relaytypes.RelayArgs, pargs relaytypes.PluginArgs) (relaytypes.MedianProvider, error) {
Expand Down

0 comments on commit 0894ae5

Please sign in to comment.