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)
| 363 | // |
| 364 | // https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_getfilterlogs |
| 365 | func (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. |