GetFilterChanges returns the logs for the filter with the given id since last time it was called. This can be used for polling. For pending transaction and block filters the result is []common.Hash. (pending)Log filters return []Log. https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_getfilterchan
(id rpc.ID)
| 397 | // |
| 398 | // https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_getfilterchanges |
| 399 | func (api *PublicFilterAPI) GetFilterChanges(id rpc.ID) (interface{}, error) { |
| 400 | api.filtersMu.Lock() |
| 401 | defer api.filtersMu.Unlock() |
| 402 | |
| 403 | if f, found := api.filters[id]; found { |
| 404 | if !f.deadline.Stop() { |
| 405 | // timer expired but filter is not yet removed in timeout loop |
| 406 | // receive timer value and reset timer |
| 407 | <-f.deadline.C |
| 408 | } |
| 409 | f.deadline.Reset(deadline) |
| 410 | |
| 411 | switch f.typ { |
| 412 | case PendingTransactionsSubscription, BlocksSubscription: |
| 413 | hashes := f.hashes |
| 414 | f.hashes = nil |
| 415 | return returnHashes(hashes), nil |
| 416 | case LogsSubscription: |
| 417 | logs := f.logs |
| 418 | f.logs = nil |
| 419 | return returnLogs(logs), nil |
| 420 | } |
| 421 | } |
| 422 | |
| 423 | return []interface{}{}, fmt.Errorf("filter not found") |
| 424 | } |
| 425 | |
| 426 | // returnHashes is a helper that will return an empty hash array case the given hash array is nil, |
| 427 | // otherwise the given hashes array is returned. |