In the JSORRPC wiki page, we can obtain a log with these format

For filters created with eth_newFilter logs are objects with following params:

removed: TAG - true when the log was removed, due to a chain reorganization. false if its a valid log.
logIndex: QUANTITY - integer of the log index position in the block. null when its pending log.

How ever when i use rpc to get a event log and found not removed field at all? Is this field be removed?

If there is no such field, how can i judge whether is log is in fork chain or in the canonical chain

  • What version of Geth are you using? Aug 24 '16 at 15:12
  • Geth Version: 1.4.10-stable-e6e25336 Protocol Versions: [63 62] Network Id: 1 Go Version: go1.6.3 OS: darwin Aug 25 '16 at 3:46

Web3 API allows you to get transaction logs before the transaction were mined (toBlock='pending'). Also, even after transaction was mined, the block where it was mined may become orphan (and then probable uncle), so transactions from it will be effectively rolled back (and probably, but not necessary, mined again in another block). It seems that geth reports log message as 'removed' in case when this log message was already returned for this filter, but later was removed from the blockchain (due to orphaned block) or never get to it (due to rejected transaction). Here is comment from geth source code:

// NewFilter creates a new filter and returns the filter id. It can be
// used to retrieve logs when the state changes. This method cannot be
// used to fetch logs that are already stored in the state.
// Default criteria for the from and to block are "latest".
// Using "latest" as block number will return logs for mined blocks.
// Using "pending" as block number returns logs for not yet mined (pending) blocks.
// In case logs are removed (chain reorg) previously returned logs are returned
// again but with the removed property set to true.
// In case "fromBlock" > "toBlock" an error is returned.
// https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_newfilter
func (api *PublicFilterAPI) NewFilter(crit FilterCriteria) (rpc.ID, error) { 

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.