@@ -177,24 +177,24 @@ done:
177177 return receipts , handled , unhandled , erroneous , err
178178}
179179
180- func (sm * BlockManager ) Process (block * Block ) (td * big.Int , err error ) {
180+ func (sm * BlockManager ) Process (block * Block ) (td * big.Int , msgs state. Messages , err error ) {
181181 // Processing a blocks may never happen simultaneously
182182 sm .mutex .Lock ()
183183 defer sm .mutex .Unlock ()
184184
185185 if sm .bc .HasBlock (block .Hash ()) {
186- return nil , nil
186+ return nil , nil , nil
187187 }
188188
189189 if ! sm .bc .HasBlock (block .PrevHash ) {
190- return nil , ParentError (block .PrevHash )
190+ return nil , nil , ParentError (block .PrevHash )
191191 }
192192 parent := sm .bc .GetBlock (block .PrevHash )
193193
194194 return sm .ProcessWithParent (block , parent )
195195}
196196
197- func (sm * BlockManager ) ProcessWithParent (block , parent * Block ) (td * big.Int , err error ) {
197+ func (sm * BlockManager ) ProcessWithParent (block , parent * Block ) (td * big.Int , messages state. Messages , err error ) {
198198 sm .lastAttemptedBlock = block
199199
200200 state := parent .State ().Copy ()
@@ -211,33 +211,36 @@ func (sm *BlockManager) ProcessWithParent(block, parent *Block) (td *big.Int, er
211211
212212 receipts , err := sm .ApplyDiff (state , parent , block )
213213 if err != nil {
214- return nil , err
214+ return
215215 }
216216 block .SetReceipts (receipts )
217217
218218 txSha := DeriveSha (block .transactions )
219219 if bytes .Compare (txSha , block .TxSha ) != 0 {
220- return nil , fmt .Errorf ("Error validating transaction sha. Received %x, got %x" , block .TxSha , txSha )
220+ err = fmt .Errorf ("Error validating transaction sha. Received %x, got %x" , block .TxSha , txSha )
221+ return
221222 }
222223
223224 receiptSha := DeriveSha (receipts )
224225 if bytes .Compare (receiptSha , block .ReceiptSha ) != 0 {
225- return nil , fmt .Errorf ("Error validating receipt sha. Received %x, got %x" , block .ReceiptSha , receiptSha )
226+ err = fmt .Errorf ("Error validating receipt sha. Received %x, got %x" , block .ReceiptSha , receiptSha )
227+ return
226228 }
227229
228230 // Block validation
229231 if err = sm .ValidateBlock (block , parent ); err != nil {
230232 statelogger .Errorln ("Error validating block:" , err )
231- return nil , err
233+ return
232234 }
233235
234236 if err = sm .AccumelateRewards (state , block , parent ); err != nil {
235237 statelogger .Errorln ("Error accumulating reward" , err )
236- return nil , err
238+ return
237239 }
238240
239241 if bytes .Compare (CreateBloom (block ), block .LogsBloom ) != 0 {
240- return nil , errors .New ("Unable to replicate block's bloom" )
242+ err = errors .New ("Unable to replicate block's bloom" )
243+ return
241244 }
242245
243246 state .Update ()
@@ -256,13 +259,14 @@ func (sm *BlockManager) ProcessWithParent(block, parent *Block) (td *big.Int, er
256259
257260 sm .transState = state .Copy ()
258261
262+ messages := state .Manifest ().Messages
259263 state .Manifest ().Reset ()
260264
261265 sm .eth .TxPool ().RemoveSet (block .Transactions ())
262266
263- return td , nil
267+ return td , messages , nil
264268 } else {
265- return nil , errors .New ("total diff failed" )
269+ return nil , nil , errors .New ("total diff failed" )
266270 }
267271}
268272
0 commit comments