good morning!!!!

Skip to content
Snippets Groups Projects
Commit c8e9ca04 authored by Jeffrey Wilcke's avatar Jeffrey Wilcke
Browse files

fixed bad uncles

parent 0330077d
No related branches found
No related tags found
No related merge requests found
......@@ -471,7 +471,8 @@ func (self *peer) getBlockHashes() bool {
self.addError(ErrInvalidBlock, "%v", err)
self.bp.status.badPeers[self.id]++
} else {
if self.currentBlock.Td != nil {
// XXX added currentBlock check (?)
if self.currentBlock != nil && self.currentBlock.Td != nil {
if self.td.Cmp(self.currentBlock.Td) != 0 {
self.addError(ErrIncorrectTD, "on block %x", self.currentBlockHash)
self.bp.status.badPeers[self.id]++
......
......@@ -7,12 +7,12 @@ import (
"time"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/state"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/event"
"github.com/ethereum/go-ethereum/logger"
"github.com/ethereum/go-ethereum/pow"
"github.com/ethereum/go-ethereum/rlp"
"github.com/ethereum/go-ethereum/core/state"
"gopkg.in/fatih/set.v0"
)
......@@ -243,7 +243,7 @@ func (sm *BlockProcessor) processWithParent(block, parent *types.Block) (td *big
chainlogger.Infof("found possible uncle block #%d (%x...)\n", header.Number, block.Hash().Bytes()[0:4])
return td, nil, BlockEqualTSErr
} else {
chainlogger.Infof("processed block #%d (%x...)\n", header.Number, block.Hash().Bytes()[0:4])
chainlogger.Infof("processed block #%d (%d TXs %d UNCs) (%x...)\n", header.Number, len(block.Transactions()), len(block.Uncles()), block.Hash().Bytes()[0:4])
}
return td, state.Logs(), nil
......
This diff is collapsed.
......@@ -9,11 +9,11 @@ import (
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core"
"github.com/ethereum/go-ethereum/core/state"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/event"
"github.com/ethereum/go-ethereum/logger"
"github.com/ethereum/go-ethereum/pow"
"github.com/ethereum/go-ethereum/core/state"
"gopkg.in/fatih/set.v0"
)
......@@ -199,6 +199,8 @@ func (self *worker) push() {
func (self *worker) commitNewWork() {
self.mu.Lock()
defer self.mu.Unlock()
self.uncleMu.Lock()
defer self.uncleMu.Unlock()
block := self.chain.NewBlock(self.coinbase)
......@@ -241,7 +243,10 @@ gasLimit:
}
self.eth.TxPool().RemoveSet(remove)
var uncles []*types.Header
var (
uncles []*types.Header
badUncles []common.Hash
)
for hash, uncle := range self.possibleUncles {
if len(uncles) == 2 {
break
......@@ -250,12 +255,16 @@ gasLimit:
if err := self.commitUncle(uncle.Header()); err != nil {
minerlogger.Infof("Bad uncle found and will be removed (%x)\n", hash[:4])
minerlogger.Debugln(uncle)
badUncles = append(badUncles, hash)
} else {
minerlogger.Infof("commiting %x as uncle\n", hash[:4])
uncles = append(uncles, uncle.Header())
}
}
minerlogger.Infof("commit new work with %d txs & %d uncles\n", tcount, len(uncles))
for _, hash := range badUncles {
delete(self.possibleUncles, hash)
}
self.current.block.SetUncles(uncles)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment