@@ -19,7 +19,6 @@ package miner
1919import (
2020 "bytes"
2121 "encoding/binary"
22- "fmt"
2322
2423 "github.com/XinFinOrg/XDPoSChain/XDCxlending/lendingstate"
2524 "github.com/XinFinOrg/XDPoSChain/accounts"
@@ -307,12 +306,7 @@ func (self *worker) update() {
307306 timeout .Reset (time .Duration (minePeriod ) * time .Second )
308307
309308 // Handle ChainSideEvent
310- case ev := <- self .chainSideCh :
311- if self .config .XDPoS == nil {
312- self .uncleMu .Lock ()
313- self .possibleUncles [ev .Block .Hash ()] = ev .Block
314- self .uncleMu .Unlock ()
315- }
309+ case <- self .chainSideCh :
316310
317311 // Handle NewTxsEvent
318312 case ev := <- self .txsCh :
@@ -508,17 +502,6 @@ func (self *worker) makeCurrent(parent *types.Block, header *types.Header) error
508502 createdAt : time .Now (),
509503 }
510504
511- if self .config .XDPoS == nil {
512- // when 08 is processed ancestors contain 07 (quick block)
513- for _ , ancestor := range self .chain .GetBlocksFromHash (parent .Hash (), 7 ) {
514- for _ , uncle := range ancestor .Uncles () {
515- work .family .Add (uncle .Hash ())
516- }
517- work .family .Add (ancestor .Hash ())
518- work .ancestors .Add (ancestor .Hash ())
519- }
520- }
521-
522505 // Keep track of transactions which return errors so they can be removed
523506 work .tcount = 0
524507 self .current = work
@@ -800,33 +783,15 @@ func (self *worker) commitNewWork() {
800783 work .commitTransactions (self .mux , feeCapacity , txs , specialTxs , self .chain , self .coinbase )
801784 // compute uncles for the new block.
802785 var (
803- uncles []* types.Header
804- badUncles []common.Hash
786+ uncles []* types.Header
805787 )
806- if self .config .XDPoS == nil {
807- for hash , uncle := range self .possibleUncles {
808- if len (uncles ) == 2 {
809- break
810- }
811- if err := self .commitUncle (work , uncle .Header ()); err != nil {
812- log .Trace ("Bad uncle found and will be removed" , "hash" , hash )
813- log .Trace (fmt .Sprint (uncle ))
814788
815- badUncles = append (badUncles , hash )
816- } else {
817- log .Debug ("Committing new uncle to block" , "hash" , hash )
818- uncles = append (uncles , uncle .Header ())
819- }
820- }
821- for _ , hash := range badUncles {
822- delete (self .possibleUncles , hash )
823- }
824- }
825789 // Create the new block to seal with the consensus engine
826790 if work .Block , err = self .engine .Finalize (self .chain , header , work .state , work .parentState , work .txs , uncles , work .receipts ); err != nil {
827791 log .Error ("Failed to finalize block for sealing" , "err" , err )
828792 return
829793 }
794+
830795 if atomic .LoadInt32 (& self .mining ) == 1 {
831796 log .Info ("Committing new block" , "number" , work .Block .Number (), "txs" , work .tcount , "special-txs" , len (specialTxs ), "uncles" , len (uncles ), "elapsed" , common .PrettyDuration (time .Since (tstart )))
832797 self .unconfirmed .Shift (work .Block .NumberU64 () - 1 )
@@ -835,21 +800,6 @@ func (self *worker) commitNewWork() {
835800 self .push (work )
836801}
837802
838- func (self * worker ) commitUncle (work * Work , uncle * types.Header ) error {
839- hash := uncle .Hash ()
840- if work .uncles .Contains (hash ) {
841- return fmt .Errorf ("uncle not unique" )
842- }
843- if ! work .ancestors .Contains (uncle .ParentHash ) {
844- return fmt .Errorf ("uncle's parent unknown (%x)" , uncle .ParentHash [0 :4 ])
845- }
846- if work .family .Contains (hash ) {
847- return fmt .Errorf ("uncle already in family (%x)" , hash )
848- }
849- work .uncles .Add (uncle .Hash ())
850- return nil
851- }
852-
853803func (env * Work ) commitTransactions (mux * event.TypeMux , balanceFee map [common.Address ]* big.Int , txs * types.TransactionsByPriceAndNonce , specialTxs types.Transactions , bc * core.BlockChain , coinbase common.Address ) {
854804 gp := new (core.GasPool ).AddGas (env .header .GasLimit )
855805 balanceUpdated := map [common.Address ]* big.Int {}
0 commit comments