Skip to content

Commit

Permalink
Reorder codec init in lp Register Filter
Browse files Browse the repository at this point in the history
  • Loading branch information
ilija42 committed Jan 14, 2025
1 parent f9c57f2 commit 577d1be
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions pkg/solana/logpoller/filters.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@ import (

"github.com/gagliardetto/solana-go"

"github.com/smartcontractkit/chainlink-common/pkg/codec/encodings/binary"
"github.com/smartcontractkit/chainlink-common/pkg/logger"

"github.com/smartcontractkit/chainlink-solana/pkg/solana/codec"
)

Expand Down Expand Up @@ -111,13 +109,6 @@ func (fl *filters) RegisterFilter(ctx context.Context, filter Filter) error {
fl.removeFilterFromIndexes(*existingFilter)
}

filterID, err := fl.orm.InsertFilter(ctx, filter)
if err != nil {
return fmt.Errorf("failed to insert filter: %w", err)
}

filter.ID = filterID

cEntry, err := codec.NewEventArgsEntry(filter.EventName, filter.EventIdl.EventIDLTypes, true, nil, binary.LittleEndian())
if err != nil {
return err
Expand All @@ -129,6 +120,13 @@ func (fl *filters) RegisterFilter(ctx context.Context, filter Filter) error {
return fmt.Errorf("failed to create event decoder: %w", err)
}

filterID, err := fl.orm.InsertFilter(ctx, filter)
if err != nil {
return fmt.Errorf("failed to insert filter: %w", err)
}

filter.ID = filterID

fl.decoders[filter.ID] = decoder
fl.filtersByName[filter.Name] = filter.ID
fl.filtersByID[filter.ID] = &filter
Expand Down

0 comments on commit 577d1be

Please sign in to comment.