mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-16 18:00:46 +00:00
remove caculate uncle block XDPoS
This commit is contained in:
parent
6ad335097c
commit
e2e75095ea
1 changed files with 29 additions and 24 deletions
|
|
@ -289,10 +289,11 @@ func (self *worker) update() {
|
||||||
|
|
||||||
// Handle ChainSideEvent
|
// Handle ChainSideEvent
|
||||||
case ev := <-self.chainSideCh:
|
case ev := <-self.chainSideCh:
|
||||||
self.uncleMu.Lock()
|
if self.config.XDPoS == nil {
|
||||||
self.possibleUncles[ev.Block.Hash()] = ev.Block
|
self.uncleMu.Lock()
|
||||||
self.uncleMu.Unlock()
|
self.possibleUncles[ev.Block.Hash()] = ev.Block
|
||||||
|
self.uncleMu.Unlock()
|
||||||
|
}
|
||||||
// Handle TxPreEvent
|
// Handle TxPreEvent
|
||||||
case ev := <-self.txCh:
|
case ev := <-self.txCh:
|
||||||
// Apply transaction to the pending state if we're not mining
|
// Apply transaction to the pending state if we're not mining
|
||||||
|
|
@ -447,13 +448,15 @@ func (self *worker) makeCurrent(parent *types.Block, header *types.Header) error
|
||||||
createdAt: time.Now(),
|
createdAt: time.Now(),
|
||||||
}
|
}
|
||||||
|
|
||||||
// when 08 is processed ancestors contain 07 (quick block)
|
if self.config.XDPoS == nil {
|
||||||
for _, ancestor := range self.chain.GetBlocksFromHash(parent.Hash(), 7) {
|
// when 08 is processed ancestors contain 07 (quick block)
|
||||||
for _, uncle := range ancestor.Uncles() {
|
for _, ancestor := range self.chain.GetBlocksFromHash(parent.Hash(), 7) {
|
||||||
work.family.Add(uncle.Hash())
|
for _, uncle := range ancestor.Uncles() {
|
||||||
|
work.family.Add(uncle.Hash())
|
||||||
|
}
|
||||||
|
work.family.Add(ancestor.Hash())
|
||||||
|
work.ancestors.Add(ancestor.Hash())
|
||||||
}
|
}
|
||||||
work.family.Add(ancestor.Hash())
|
|
||||||
work.ancestors.Add(ancestor.Hash())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Keep track of transactions which return errors so they can be removed
|
// Keep track of transactions which return errors so they can be removed
|
||||||
|
|
@ -608,22 +611,24 @@ func (self *worker) commitNewWork() {
|
||||||
uncles []*types.Header
|
uncles []*types.Header
|
||||||
badUncles []common.Hash
|
badUncles []common.Hash
|
||||||
)
|
)
|
||||||
for hash, uncle := range self.possibleUncles {
|
if self.config.XDPoS == nil {
|
||||||
if len(uncles) == 2 {
|
for hash, uncle := range self.possibleUncles {
|
||||||
break
|
if len(uncles) == 2 {
|
||||||
}
|
break
|
||||||
if err := self.commitUncle(work, uncle.Header()); err != nil {
|
}
|
||||||
log.Trace("Bad uncle found and will be removed", "hash", hash)
|
if err := self.commitUncle(work, uncle.Header()); err != nil {
|
||||||
log.Trace(fmt.Sprint(uncle))
|
log.Trace("Bad uncle found and will be removed", "hash", hash)
|
||||||
|
log.Trace(fmt.Sprint(uncle))
|
||||||
|
|
||||||
badUncles = append(badUncles, hash)
|
badUncles = append(badUncles, hash)
|
||||||
} else {
|
} else {
|
||||||
log.Debug("Committing new uncle to block", "hash", hash)
|
log.Debug("Committing new uncle to block", "hash", hash)
|
||||||
uncles = append(uncles, uncle.Header())
|
uncles = append(uncles, uncle.Header())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for _, hash := range badUncles {
|
||||||
|
delete(self.possibleUncles, hash)
|
||||||
}
|
}
|
||||||
}
|
|
||||||
for _, hash := range badUncles {
|
|
||||||
delete(self.possibleUncles, hash)
|
|
||||||
}
|
}
|
||||||
// Create the new block to seal with the consensus engine
|
// Create the new block to seal with the consensus engine
|
||||||
if work.Block, err = self.engine.Finalize(self.chain, header, work.state, work.txs, uncles, work.receipts); err != nil {
|
if work.Block, err = self.engine.Finalize(self.chain, header, work.state, work.txs, uncles, work.receipts); err != nil {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue