Skip to content

Commit

Permalink
change event sig type, assigning subkey values to idx, remove unused …
Browse files Browse the repository at this point in the history
…code
  • Loading branch information
EasterTheBunny committed Feb 19, 2025
1 parent f8c342c commit f3e8052
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 14 deletions.
9 changes: 0 additions & 9 deletions pkg/solana/logpoller/loader.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,6 @@ type Block struct {
Events []ProgramEvent
}

type ProgramEventProcessor interface {
// Process should take a ProgramEvent and parseProgramLogs it based on log signature
// and expected encoding. Only return errors that cannot be handled and
// should exit further transaction processing on the running thread.
//
// Process should be thread safe.
Process(Block) error
}

type RPCClient interface {
GetBlockWithOpts(context.Context, uint64, *rpc.GetBlockOpts) (*rpc.GetBlockResult, error)
GetSignaturesForAddressWithOpts(context.Context, solana.PublicKey, *rpc.GetSignaturesForAddressOpts) ([]*rpc.TransactionSignature, error)
Expand Down
12 changes: 9 additions & 3 deletions pkg/solana/logpoller/log_poller.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,17 +175,23 @@ func (lp *Service) Process(ctx context.Context, programEvent ProgramEvent) (err
return err
}

log.SubkeyValues = make([]IndexedValue, 0, len(filter.SubkeyPaths))
for _, path := range filter.SubkeyPaths {
log.SubkeyValues = make([]IndexedValue, len(filter.SubkeyPaths))
for idx, path := range filter.SubkeyPaths {
if len(path) == 0 {
continue
}

subKeyVal, decodeSubKeyErr := lp.filters.DecodeSubKey(ctx, lp.lggr, log.Data, filter.ID, path)
if decodeSubKeyErr != nil {
return decodeSubKeyErr
}

indexedVal, newIndexedValErr := newIndexedValue(subKeyVal)
if newIndexedValErr != nil {
return newIndexedValErr
}
log.SubkeyValues = append(log.SubkeyValues, indexedVal)

log.SubkeyValues[idx] = indexedVal
}

log.SequenceNum = lp.filters.IncrementSeqNum(filter.ID)
Expand Down
8 changes: 6 additions & 2 deletions pkg/solana/logpoller/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -429,12 +429,16 @@ func (f *addressFilter) Accept(visitor primitives.Visitor) {
}

type eventSigFilter struct {
eventSig []byte
eventSig EventSignature
}

func NewEventSigFilter(sig []byte) query.Expression {
var eventSig EventSignature

copy(eventSig[:], sig[:])

return query.Expression{
Primitive: &eventSigFilter{eventSig: sig},
Primitive: &eventSigFilter{eventSig: eventSig},
}
}

Expand Down

0 comments on commit f3e8052

Please sign in to comment.