aboutsummaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2015-02-05 07:05:47 +0800
committerobscuren <geffobscura@gmail.com>2015-02-05 07:05:47 +0800
commit65158d39b0632226c168b9a3415365ca8f072cbf (patch)
tree9b8bb62fa6b2a056a85a889f7f8609aca0a6f875 /core
parentb1870631a4829e075eae77064973ef94aa2166b3 (diff)
downloaddexon-65158d39b0632226c168b9a3415365ca8f072cbf.tar.gz
dexon-65158d39b0632226c168b9a3415365ca8f072cbf.tar.zst
dexon-65158d39b0632226c168b9a3415365ca8f072cbf.zip
Filtering
Diffstat (limited to 'core')
-rw-r--r--core/block_processor.go13
-rw-r--r--core/chain_manager.go3
-rw-r--r--core/filter.go7
-rw-r--r--core/types/common.go8
4 files changed, 17 insertions, 14 deletions
diff --git a/core/block_processor.go b/core/block_processor.go
index 20a651e84..d59d7feca 100644
--- a/core/block_processor.go
+++ b/core/block_processor.go
@@ -110,6 +110,8 @@ func (self *BlockProcessor) ApplyTransaction(coinbase *state.StateObject, state
go self.eventMux.Post(TxPostEvent{tx})
}
+ go self.eventMux.Post(state.Logs())
+
return receipt, txGas, err
}
@@ -155,25 +157,25 @@ done:
return receipts, handled, unhandled, erroneous, err
}
-func (sm *BlockProcessor) Process(block *types.Block) (td *big.Int, msgs state.Messages, err error) {
+func (sm *BlockProcessor) Process(block *types.Block) (td *big.Int, err error) {
// Processing a blocks may never happen simultaneously
sm.mutex.Lock()
defer sm.mutex.Unlock()
header := block.Header()
if sm.bc.HasBlock(header.Hash()) {
- return nil, nil, &KnownBlockError{header.Number, header.Hash()}
+ return nil, &KnownBlockError{header.Number, header.Hash()}
}
if !sm.bc.HasBlock(header.ParentHash) {
- return nil, nil, ParentError(header.ParentHash)
+ return nil, ParentError(header.ParentHash)
}
parent := sm.bc.GetBlock(header.ParentHash)
return sm.ProcessWithParent(block, parent)
}
-func (sm *BlockProcessor) ProcessWithParent(block, parent *types.Block) (td *big.Int, messages state.Messages, err error) {
+func (sm *BlockProcessor) ProcessWithParent(block, parent *types.Block) (td *big.Int, err error) {
sm.lastAttemptedBlock = block
state := state.New(parent.Root(), sm.db)
@@ -227,7 +229,6 @@ func (sm *BlockProcessor) ProcessWithParent(block, parent *types.Block) (td *big
state.Sync()
// Set the block hashes for the current messages
state.Manifest().SetHash(block.Hash())
- messages = state.Manifest().Messages
// Reset the manifest XXX We need this?
state.Manifest().Reset()
// Remove transactions from the pool
@@ -235,7 +236,7 @@ func (sm *BlockProcessor) ProcessWithParent(block, parent *types.Block) (td *big
chainlogger.Infof("processed block #%d (%x...)\n", header.Number, block.Hash()[0:4])
- return td, messages, nil
+ return td, nil
}
// Validates the current block. Returns an error if the block was invalid,
diff --git a/core/chain_manager.go b/core/chain_manager.go
index 9646bfc53..0847980ca 100644
--- a/core/chain_manager.go
+++ b/core/chain_manager.go
@@ -359,7 +359,7 @@ func (bc *ChainManager) Stop() {
func (self *ChainManager) InsertChain(chain types.Blocks) error {
for _, block := range chain {
- td, messages, err := self.processor.Process(block)
+ td, err := self.processor.Process(block)
if err != nil {
if IsKnownBlockErr(err) {
continue
@@ -391,7 +391,6 @@ func (self *ChainManager) InsertChain(chain types.Blocks) error {
self.mu.Unlock()
self.eventMux.Post(NewBlockEvent{block})
- self.eventMux.Post(messages)
}
return nil
diff --git a/core/filter.go b/core/filter.go
index d154e7b7a..a458165f5 100644
--- a/core/filter.go
+++ b/core/filter.go
@@ -2,6 +2,7 @@ package core
import (
"bytes"
+ "fmt"
"math"
"github.com/ethereum/go-ethereum/core/types"
@@ -130,6 +131,7 @@ func (self *Filter) Find() state.Logs {
func includes(addresses [][]byte, a []byte) (found bool) {
for _, addr := range addresses {
+ fmt.Println("INCLUDES", addr, a)
if bytes.Compare(addr, a) == 0 {
return true
}
@@ -139,20 +141,25 @@ func includes(addresses [][]byte, a []byte) (found bool) {
}
func (self *Filter) FilterLogs(logs state.Logs) state.Logs {
+ fmt.Println("FILTER LOGS", self.topics)
var ret state.Logs
// Filter the logs for interesting stuff
for _, log := range logs {
+ fmt.Println(log)
+
if len(self.address) > 0 && !bytes.Equal(self.address, log.Address()) {
continue
}
for _, topic := range self.topics {
+ fmt.Println("TOPIC:", topic)
if !includes(log.Topics(), topic) {
continue
}
}
+ fmt.Println("APPENDED")
ret = append(ret, log)
}
diff --git a/core/types/common.go b/core/types/common.go
index ba88b77e1..795374959 100644
--- a/core/types/common.go
+++ b/core/types/common.go
@@ -1,11 +1,7 @@
package types
-import (
- "math/big"
-
- "github.com/ethereum/go-ethereum/state"
-)
+import "math/big"
type BlockProcessor interface {
- Process(*Block) (*big.Int, state.Messages, error)
+ Process(*Block) (*big.Int, error)
}