refactor: pass struct through pipeline fllters

This commit is contained in:
Mohamed Sohail 2023-02-24 07:48:47 +00:00
parent 85ef2ffaac
commit 4b2eb7b018
Signed by: kamikazechaser
GPG Key ID: 7DD45520C01CD85D
7 changed files with 7 additions and 7 deletions

View File

@ -25,7 +25,7 @@ func NewAddressFilter(o AddressFilterOpts) Filter {
}
}
func (f *AddressFilter) Execute(_ context.Context, transaction *fetch.Transaction) (bool, error) {
func (f *AddressFilter) Execute(_ context.Context, transaction fetch.Transaction) (bool, error) {
if _, found := f.cache.Load(transaction.To.Address); found {
return true, nil
}

View File

@ -66,7 +66,7 @@ func (s *AddressFilterSuite) TestAddresses() {
}
for _, test := range tests {
next, err := s.filter.Execute(context.Background(), &test.transactionData)
next, err := s.filter.Execute(context.Background(), test.transactionData)
s.NoError(err)
s.Equal(test.want, next)
}

View File

@ -8,5 +8,5 @@ import (
// Filter defines a read only filter which must return next as true/false or an error
type Filter interface {
Execute(ctx context.Context, inputTransaction *fetch.Transaction) (next bool, err error)
Execute(ctx context.Context, inputTransaction fetch.Transaction) (next bool, err error)
}

View File

@ -40,7 +40,7 @@ func NewGasFilter(o GasFilterOpts) Filter {
}
}
func (f *GasFilter) Execute(_ context.Context, transaction *fetch.Transaction) (bool, error) {
func (f *GasFilter) Execute(_ context.Context, transaction fetch.Transaction) (bool, error) {
switch transaction.InputData[:10] {
case "0x63e4bff4":
var (

View File

@ -46,7 +46,7 @@ func NewTransferFilter(o TransferFilterOpts) Filter {
}
}
func (f *TransferFilter) Execute(_ context.Context, transaction *fetch.Transaction) (bool, error) {
func (f *TransferFilter) Execute(_ context.Context, transaction fetch.Transaction) (bool, error) {
switch transaction.InputData[:10] {
case "0xa9059cbb":
var (

View File

@ -66,7 +66,7 @@ func (s *TransferFilterSuite) TestTranfserInputs() {
}
for _, test := range tests {
next, err := s.filter.Execute(context.Background(), &test.transactionData)
next, err := s.filter.Execute(context.Background(), test.transactionData)
s.NoError(err)
s.Equal(test.want, next)
}

View File

@ -49,7 +49,7 @@ func (md *Pipeline) Run(ctx context.Context, blockNumber uint64) error {
for _, tx := range fetchResp.Data.Block.Transactions {
for _, filter := range md.filters {
next, err := filter.Execute(ctx, &tx)
next, err := filter.Execute(ctx, tx)
if err != nil {
return err
}