diff options
author | obscuren <geffobscura@gmail.com> | 2015-03-19 23:19:54 +0800 |
---|---|---|
committer | obscuren <geffobscura@gmail.com> | 2015-03-19 23:19:54 +0800 |
commit | 14a2f42f3700640f191e0095b50a266d2a919b38 (patch) | |
tree | e22528f68c7bdab57a8cdfbcddc29df06c15457a /core/block_processor.go | |
parent | b52807f0c0ff1b89cc1d7172ce1b768a34d02b00 (diff) | |
download | go-tangerine-14a2f42f3700640f191e0095b50a266d2a919b38.tar go-tangerine-14a2f42f3700640f191e0095b50a266d2a919b38.tar.gz go-tangerine-14a2f42f3700640f191e0095b50a266d2a919b38.tar.bz2 go-tangerine-14a2f42f3700640f191e0095b50a266d2a919b38.tar.lz go-tangerine-14a2f42f3700640f191e0095b50a266d2a919b38.tar.xz go-tangerine-14a2f42f3700640f191e0095b50a266d2a919b38.tar.zst go-tangerine-14a2f42f3700640f191e0095b50a266d2a919b38.zip |
fixed chain event. Closes #529
Diffstat (limited to 'core/block_processor.go')
-rw-r--r-- | core/block_processor.go | 20 |
1 files changed, 8 insertions, 12 deletions
diff --git a/core/block_processor.go b/core/block_processor.go index f67d6d006..62c9c92a6 100644 --- a/core/block_processor.go +++ b/core/block_processor.go @@ -7,8 +7,8 @@ import ( "sync" "time" - "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/event" "github.com/ethereum/go-ethereum/logger" "github.com/ethereum/go-ethereum/pow" @@ -17,10 +17,6 @@ import ( "gopkg.in/fatih/set.v0" ) -type PendingBlockEvent struct { - Block *types.Block -} - var statelogger = logger.NewLogger("BLOCK") type BlockProcessor struct { @@ -137,7 +133,7 @@ func (self *BlockProcessor) ApplyTransactions(coinbase *state.StateObject, state block.Header().GasUsed = totalUsedGas if transientProcess { - go self.eventMux.Post(PendingBlockEvent{block}) + go self.eventMux.Post(PendingBlockEvent{block, statedb.Logs()}) } return receipts, handled, unhandled, erroneous, err @@ -146,25 +142,25 @@ func (self *BlockProcessor) ApplyTransactions(coinbase *state.StateObject, state // Process block will attempt to process the given block's transactions and applies them // on top of the block's parent state (given it exists) and will return wether it was // successful or not. -func (sm *BlockProcessor) Process(block *types.Block) (td *big.Int, err error) { +func (sm *BlockProcessor) Process(block *types.Block) (td *big.Int, logs state.Logs, 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, &KnownBlockError{header.Number, header.Hash()} + return nil, nil, &KnownBlockError{header.Number, header.Hash()} } if !sm.bc.HasBlock(header.ParentHash) { - return nil, ParentError(header.ParentHash) + return nil, 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, err error) { +func (sm *BlockProcessor) processWithParent(block, parent *types.Block) (td *big.Int, logs state.Logs, err error) { sm.lastAttemptedBlock = block // Create a new state based on the parent's root (e.g., create copy) @@ -177,7 +173,7 @@ func (sm *BlockProcessor) processWithParent(block, parent *types.Block) (td *big // There can be at most two uncles if len(block.Uncles()) > 2 { - return nil, ValidationError("Block can only contain one uncle (contained %v)", len(block.Uncles())) + return nil, nil, ValidationError("Block can only contain one uncle (contained %v)", len(block.Uncles())) } receipts, err := sm.TransitionState(state, parent, block, false) @@ -236,7 +232,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, nil + return td, state.Logs(), nil } // Validates the current block. Returns an error if the block was invalid, |