Added eth_logs & fixed issue with manual log filtering
* Implemented `eth_logs` * Fixed issue with `filter.Find()` where logs were appended to an incorrect, non-returned slice resulting in no logs found
This commit is contained in:
@ -60,12 +60,12 @@ func NewBlockProcessor(db ethutil.Database, txpool *TxPool, chainManager *ChainM
|
||||
return sm
|
||||
}
|
||||
|
||||
func (sm *BlockProcessor) TransitionState(statedb *state.StateDB, parent, block *types.Block) (receipts types.Receipts, err error) {
|
||||
func (sm *BlockProcessor) TransitionState(statedb *state.StateDB, parent, block *types.Block, transientProcess bool) (receipts types.Receipts, err error) {
|
||||
coinbase := statedb.GetOrNewStateObject(block.Header().Coinbase)
|
||||
coinbase.SetGasPool(CalcGasLimit(parent, block))
|
||||
|
||||
// Process the transactions on to parent state
|
||||
receipts, _, _, _, err = sm.ApplyTransactions(coinbase, statedb, block, block.Transactions(), false)
|
||||
receipts, _, _, _, err = sm.ApplyTransactions(coinbase, statedb, block, block.Transactions(), transientProcess)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -100,10 +100,9 @@ func (self *BlockProcessor) ApplyTransaction(coinbase *state.StateObject, stated
|
||||
// Notify all subscribers
|
||||
if !transientProcess {
|
||||
go self.eventMux.Post(TxPostEvent{tx})
|
||||
go self.eventMux.Post(statedb.Logs())
|
||||
}
|
||||
|
||||
go self.eventMux.Post(statedb.Logs())
|
||||
|
||||
return receipt, txGas, err
|
||||
}
|
||||
|
||||
@ -179,7 +178,7 @@ func (sm *BlockProcessor) processWithParent(block, parent *types.Block) (td *big
|
||||
return
|
||||
}
|
||||
|
||||
receipts, err := sm.TransitionState(state, parent, block)
|
||||
receipts, err := sm.TransitionState(state, parent, block, false)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
@ -316,13 +315,10 @@ func (sm *BlockProcessor) GetLogs(block *types.Block) (logs state.Logs, err erro
|
||||
|
||||
var (
|
||||
parent = sm.bc.GetBlock(block.Header().ParentHash)
|
||||
//state = state.New(parent.Trie().Copy())
|
||||
state = state.New(parent.Root(), sm.db)
|
||||
state = state.New(parent.Root(), sm.db)
|
||||
)
|
||||
|
||||
defer state.Reset()
|
||||
|
||||
sm.TransitionState(state, parent, block)
|
||||
sm.TransitionState(state, parent, block, true)
|
||||
sm.AccumulateRewards(state, block, parent)
|
||||
|
||||
return state.Logs(), nil
|
||||
|
@ -111,14 +111,14 @@ func (self *Filter) Find() state.Logs {
|
||||
// current parameters
|
||||
if self.bloomFilter(block) {
|
||||
// Get the logs of the block
|
||||
logs, err := self.eth.BlockProcessor().GetLogs(block)
|
||||
unfiltered, err := self.eth.BlockProcessor().GetLogs(block)
|
||||
if err != nil {
|
||||
chainlogger.Warnln("err: filter get logs ", err)
|
||||
|
||||
break
|
||||
}
|
||||
|
||||
logs = append(logs, self.FilterLogs(logs)...)
|
||||
logs = append(logs, self.FilterLogs(unfiltered)...)
|
||||
}
|
||||
|
||||
block = self.eth.ChainManager().GetBlock(block.ParentHash())
|
||||
@ -146,7 +146,6 @@ func (self *Filter) FilterLogs(logs state.Logs) state.Logs {
|
||||
Logs:
|
||||
for _, log := range logs {
|
||||
if !includes(self.address, log.Address()) {
|
||||
//if !bytes.Equal(self.address, log.Address()) {
|
||||
continue
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user