|
|
@ -34,6 +34,7 @@ type Backend interface { |
|
|
|
EventMux() *event.TypeMux |
|
|
|
EventMux() *event.TypeMux |
|
|
|
HeaderByNumber(ctx context.Context, blockNr rpc.BlockNumber) (*types.Header, error) |
|
|
|
HeaderByNumber(ctx context.Context, blockNr rpc.BlockNumber) (*types.Header, error) |
|
|
|
GetReceipts(ctx context.Context, blockHash common.Hash) (types.Receipts, error) |
|
|
|
GetReceipts(ctx context.Context, blockHash common.Hash) (types.Receipts, error) |
|
|
|
|
|
|
|
GetLogs(ctx context.Context, blockHash common.Hash) ([][]*types.Log, error) |
|
|
|
|
|
|
|
|
|
|
|
SubscribeTxPreEvent(chan<- core.TxPreEvent) event.Subscription |
|
|
|
SubscribeTxPreEvent(chan<- core.TxPreEvent) event.Subscription |
|
|
|
SubscribeChainEvent(ch chan<- core.ChainEvent) event.Subscription |
|
|
|
SubscribeChainEvent(ch chan<- core.ChainEvent) event.Subscription |
|
|
@ -201,16 +202,28 @@ func (f *Filter) unindexedLogs(ctx context.Context, end uint64) ([]*types.Log, e |
|
|
|
// match the filter criteria. This function is called when the bloom filter signals a potential match.
|
|
|
|
// match the filter criteria. This function is called when the bloom filter signals a potential match.
|
|
|
|
func (f *Filter) checkMatches(ctx context.Context, header *types.Header) (logs []*types.Log, err error) { |
|
|
|
func (f *Filter) checkMatches(ctx context.Context, header *types.Header) (logs []*types.Log, err error) { |
|
|
|
// Get the logs of the block
|
|
|
|
// Get the logs of the block
|
|
|
|
receipts, err := f.backend.GetReceipts(ctx, header.Hash()) |
|
|
|
logsList, err := f.backend.GetLogs(ctx, header.Hash()) |
|
|
|
if err != nil { |
|
|
|
if err != nil { |
|
|
|
return nil, err |
|
|
|
return nil, err |
|
|
|
} |
|
|
|
} |
|
|
|
var unfiltered []*types.Log |
|
|
|
var unfiltered []*types.Log |
|
|
|
for _, receipt := range receipts { |
|
|
|
for _, logs := range logsList { |
|
|
|
unfiltered = append(unfiltered, receipt.Logs...) |
|
|
|
unfiltered = append(unfiltered, logs...) |
|
|
|
} |
|
|
|
} |
|
|
|
logs = filterLogs(unfiltered, nil, nil, f.addresses, f.topics) |
|
|
|
logs = filterLogs(unfiltered, nil, nil, f.addresses, f.topics) |
|
|
|
if len(logs) > 0 { |
|
|
|
if len(logs) > 0 { |
|
|
|
|
|
|
|
// We have matching logs, check if we need to resolve full logs via the light client
|
|
|
|
|
|
|
|
if logs[0].TxHash == (common.Hash{}) { |
|
|
|
|
|
|
|
receipts, err := f.backend.GetReceipts(ctx, header.Hash()) |
|
|
|
|
|
|
|
if err != nil { |
|
|
|
|
|
|
|
return nil, err |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
unfiltered = unfiltered[:0] |
|
|
|
|
|
|
|
for _, receipt := range receipts { |
|
|
|
|
|
|
|
unfiltered = append(unfiltered, receipt.Logs...) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
logs = filterLogs(unfiltered, nil, nil, f.addresses, f.topics) |
|
|
|
|
|
|
|
} |
|
|
|
return logs, nil |
|
|
|
return logs, nil |
|
|
|
} |
|
|
|
} |
|
|
|
return nil, nil |
|
|
|
return nil, nil |
|
|
|