MCPcopy Create free account
hub / github.com/CPChain/chain / GetFilterLogs

Method GetFilterLogs

protocols/cpc/filters/api.go:365–390  ·  view source on GitHub ↗

GetFilterLogs returns the logs for the filter with the given id. If the filter could not be found an empty array of logs is returned. https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_getfilterlogs

(ctx context.Context, id rpc.ID)

Source from the content-addressed store, hash-verified

363//
364// https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_getfilterlogs
365func (api *PublicFilterAPI) GetFilterLogs(ctx context.Context, id rpc.ID) ([]*types.Log, error) {
366 api.filtersMu.Lock()
367 f, found := api.filters[id]
368 api.filtersMu.Unlock()
369
370 if !found || f.typ != LogsSubscription {
371 return nil, fmt.Errorf("filter not found")
372 }
373
374 begin := rpc.LatestBlockNumber.Int64()
375 if f.crit.FromBlock != nil {
376 begin = f.crit.FromBlock.Int64()
377 }
378 end := rpc.LatestBlockNumber.Int64()
379 if f.crit.ToBlock != nil {
380 end = f.crit.ToBlock.Int64()
381 }
382 // Create and run the filter to get all the logs
383 filter := New(api.backend, begin, end, f.crit.Addresses, f.crit.Topics)
384
385 logs, err := filter.Logs(ctx)
386 if err != nil {
387 return nil, err
388 }
389 return returnLogs(logs), nil
390}
391
392// GetFilterChanges returns the logs for the filter with the given id since
393// last time it was called. This can be used for polling.

Callers

nothing calls this directly

Calls 6

returnLogsFunction · 0.85
LockMethod · 0.80
UnlockMethod · 0.80
Int64Method · 0.80
NewFunction · 0.70
LogsMethod · 0.45

Tested by

no test coverage detected