Skip to content

Commit

Permalink
remove tuple
Browse files Browse the repository at this point in the history
  • Loading branch information
EasterTheBunny committed Feb 3, 2025
1 parent 748b44f commit 7b111bd
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 12 deletions.
6 changes: 3 additions & 3 deletions pkg/solana/chainreader/chain_reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ func (s *ContractReaderService) addEventRead(
readDefinition config.ReadDefinition,
events EventsReader,
) error {
mappedTuples := make(map[string]subkeyTuple)
mappedTuples := make(map[string]uint64)
subKeys := [4][]string{}

applyIndexedFieldTuple(mappedTuples, subKeys, readDefinition.IndexedField0, 0)
Expand Down Expand Up @@ -466,9 +466,9 @@ func toLPFilter(
}
}

func applyIndexedFieldTuple(lookup map[string]subkeyTuple, subKeys [4][]string, conf *config.IndexedField, idx uint64) {
func applyIndexedFieldTuple(lookup map[string]uint64, subKeys [4][]string, conf *config.IndexedField, idx uint64) {
if conf != nil {
lookup[conf.OffChainPath] = subkeyTuple{conf.OnChainPath, idx}
lookup[conf.OffChainPath] = idx
subKeys[idx] = strings.Split(conf.OnChainPath, ".")
}
}
13 changes: 4 additions & 9 deletions pkg/solana/chainreader/event_read_binding.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,25 +17,20 @@ import (
"github.com/smartcontractkit/chainlink-solana/pkg/solana/logpoller"
)

type subkeyTuple struct {
string
uint64
}

type eventReadBinding struct {
namespace, genericName string
codec types.RemoteCodec
modifier commoncodec.Modifier
key solana.PublicKey
remapper remapHelper
indexedSubKeys map[string]subkeyTuple
indexedSubKeys map[string]uint64
reader EventsReader
eventSig [logpoller.EventSignatureLength]byte
}

func newEventReadBinding(
namespace, genericName string,
indexedSubKeys map[string]subkeyTuple,
indexedSubKeys map[string]uint64,
reader EventsReader,
eventSig [logpoller.EventSignatureLength]byte,
) *eventReadBinding {
Expand Down Expand Up @@ -140,7 +135,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]
subKeyIndex, ok := b.indexedSubKeys[comparator.Name]
if !ok {
return query.Expression{}, fmt.Errorf("%w: unknown indexed subkey mapping %s", types.ErrInvalidConfig, comparator.Name)
}
Expand All @@ -157,7 +152,7 @@ func (b *eventReadBinding) encodeComparator(comparator *primitives.Comparator) (
comparator.ValueComparators[idx].Value = newValue
}

return logpoller.NewEventBySubKeyFilter(onChainTuple.uint64, comparator.ValueComparators)
return logpoller.NewEventBySubKeyFilter(subKeyIndex, comparator.ValueComparators)
}

func (b *eventReadBinding) decodeLogsIntoSequences(
Expand Down

0 comments on commit 7b111bd

Please sign in to comment.