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

Method GetFilterChanges

protocols/cpc/filters/api.go:399–424  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

397//
398// https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_getfilterchanges
399func (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.

Callers 2

TestPendingTxFilterFunction · 0.80
TestLogFilterFunction · 0.80

Calls 6

returnHashesFunction · 0.85
returnLogsFunction · 0.85
LockMethod · 0.80
UnlockMethod · 0.80
StopMethod · 0.65
ResetMethod · 0.65

Tested by 2

TestPendingTxFilterFunction · 0.64
TestLogFilterFunction · 0.64