@@ -2185,7 +2185,7 @@ func (bc *BlockChain) collectLogs(b *types.Block, removed bool) []*types.Log {
21852185// externally.
21862186func (bc * BlockChain ) reorg (oldHead * types.Header , newHead * types.Block ) error {
21872187 var (
2188- newChain types.Blocks
2188+ newChain [] * types.Header
21892189 oldChain []* types.Header
21902190 commonBlock * types.Block
21912191
@@ -2210,7 +2210,7 @@ func (bc *BlockChain) reorg(oldHead *types.Header, newHead *types.Block) error {
22102210 } else {
22112211 // New chain is longer, stash all blocks away for subsequent insertion
22122212 for ; newBlock != nil && newBlock .NumberU64 () != oldBlock .NumberU64 (); newBlock = bc .GetBlock (newBlock .ParentHash (), newBlock .NumberU64 ()- 1 ) {
2213- newChain = append (newChain , newBlock )
2213+ newChain = append (newChain , newBlock . Header () )
22142214 }
22152215 }
22162216 if oldBlock == nil {
@@ -2232,7 +2232,7 @@ func (bc *BlockChain) reorg(oldHead *types.Header, newHead *types.Block) error {
22322232 for _ , tx := range oldBlock .Transactions () {
22332233 deletedTxs = append (deletedTxs , tx .Hash ())
22342234 }
2235- newChain = append (newChain , newBlock )
2235+ newChain = append (newChain , newBlock . Header () )
22362236
22372237 // Step back with both chains
22382238 oldBlock = bc .GetBlock (oldBlock .ParentHash (), oldBlock .NumberU64 ()- 1 )
@@ -2282,10 +2282,11 @@ func (bc *BlockChain) reorg(oldHead *types.Header, newHead *types.Block) error {
22822282 // as it will be handled separately outside of this function
22832283 for i := len (newChain ) - 1 ; i >= 1 ; i -- {
22842284 // Insert the block in the canonical way, re-writing history
2285- bc .writeHeadBlock (newChain [i ])
2285+ newBlock = bc .GetBlock (newChain [i ].Hash (), newChain [i ].Number .Uint64 ())
2286+ bc .writeHeadBlock (newBlock )
22862287
22872288 // Collect the new added transactions.
2288- for _ , tx := range newChain [ i ] .Transactions () {
2289+ for _ , tx := range newBlock .Transactions () {
22892290 addedTxs = append (addedTxs , tx .Hash ())
22902291 }
22912292 }
@@ -2304,7 +2305,7 @@ func (bc *BlockChain) reorg(oldHead *types.Header, newHead *types.Block) error {
23042305 // markers greater than or equal to new chain head should be deleted.
23052306 number := commonBlock .NumberU64 ()
23062307 if len (newChain ) > 1 {
2307- number = newChain [1 ].NumberU64 ()
2308+ number = newChain [1 ].Number . Uint64 ()
23082309 }
23092310 for i := number + 1 ; ; i ++ {
23102311 hash := rawdb .ReadCanonicalHash (bc .db , i )
@@ -2346,7 +2347,8 @@ func (bc *BlockChain) reorg(oldHead *types.Header, newHead *types.Block) error {
23462347 // New logs:
23472348 var rebirthLogs []* types.Log
23482349 for i := len (newChain ) - 1 ; i >= 1 ; i -- {
2349- if logs := bc .collectLogs (newChain [i ], false ); len (logs ) > 0 {
2350+ newBlock = bc .GetBlock (newChain [i ].Hash (), newChain [i ].Number .Uint64 ())
2351+ if logs := bc .collectLogs (newBlock , false ); len (logs ) > 0 {
23502352 rebirthLogs = append (rebirthLogs , logs ... )
23512353 }
23522354 if len (rebirthLogs ) > 512 {
0 commit comments