@@ -61,7 +61,7 @@ func (sm *BlockProcessor) TransitionState(statedb *state.StateDB, parent, block
6161 coinbase .SetGasPool (block .Header ().GasLimit )
6262
6363 // Process the transactions on to parent state
64- receipts , _ , _ , _ , err = sm .ApplyTransactions (coinbase , statedb , block , block .Transactions (), transientProcess )
64+ receipts , err = sm .ApplyTransactions (coinbase , statedb , block , block .Transactions (), transientProcess )
6565 if err != nil {
6666 return nil , err
6767 }
@@ -104,39 +104,38 @@ func (self *BlockProcessor) ChainManager() *ChainManager {
104104 return self .bc
105105}
106106
107- func (self * BlockProcessor ) ApplyTransactions (coinbase * state.StateObject , statedb * state.StateDB , block * types.Block , txs types.Transactions , transientProcess bool ) (types.Receipts , types. Transactions , types. Transactions , types. Transactions , error ) {
107+ func (self * BlockProcessor ) ApplyTransactions (coinbase * state.StateObject , statedb * state.StateDB , block * types.Block , txs types.Transactions , transientProcess bool ) (types.Receipts , error ) {
108108 var (
109- receipts types.Receipts
110- handled , unhandled types.Transactions
111- erroneous types.Transactions
112- totalUsedGas = big .NewInt (0 )
113- err error
114- cumulativeSum = new (big.Int )
109+ receipts types.Receipts
110+ totalUsedGas = big .NewInt (0 )
111+ err error
112+ cumulativeSum = new (big.Int )
115113 )
116114
117115 for _ , tx := range txs {
118116 receipt , txGas , err := self .ApplyTransaction (coinbase , statedb , block , tx , totalUsedGas , transientProcess )
119117 if err != nil && (IsNonceErr (err ) || state .IsGasLimitErr (err ) || IsInvalidTxErr (err )) {
120- return nil , nil , nil , nil , err
118+ return nil , err
121119 }
122120
123121 if err != nil {
124122 statelogger .Infoln ("TX err:" , err )
125123 }
126124 receipts = append (receipts , receipt )
127- handled = append (handled , tx )
128125
129126 cumulativeSum .Add (cumulativeSum , new (big.Int ).Mul (txGas , tx .GasPrice ()))
130127 }
131128
132129 block .Reward = cumulativeSum
133- block .Header ().GasUsed = totalUsedGas
130+ if block .GasUsed ().Cmp (totalUsedGas ) != 0 {
131+ return nil , ValidationError (fmt .Sprintf ("gas used error (%v / %v)" , block .GasUsed (), totalUsedGas ))
132+ }
134133
135134 if transientProcess {
136135 go self .eventMux .Post (PendingBlockEvent {block , statedb .Logs ()})
137136 }
138137
139- return receipts , handled , unhandled , erroneous , err
138+ return receipts , err
140139}
141140
142141// Process block will attempt to process the given block's transactions and applies them
0 commit comments