mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-19 18:32:23 +00:00
change difficulty block in posv
This commit is contained in:
parent
407a556362
commit
2ef491ea4e
6 changed files with 12 additions and 9 deletions
|
|
@ -151,7 +151,7 @@ func BenchmarkAddressHex(b *testing.B) {
|
|||
}
|
||||
|
||||
func TestRemoveItemInArray(t *testing.T) {
|
||||
array := []Address{HexToAddress("0x0000003"),HexToAddress("0x0000001"), HexToAddress("0x0000002"),HexToAddress("0x0000003")}
|
||||
array := []Address{HexToAddress("0x0000003"), HexToAddress("0x0000001"), HexToAddress("0x0000002"), HexToAddress("0x0000003")}
|
||||
remove := []Address{HexToAddress("0x0000002"), HexToAddress("0x0000004"), HexToAddress("0x0000003")}
|
||||
array = RemoveItemFromArray(array, remove)
|
||||
if len(array) != 1 {
|
||||
|
|
|
|||
|
|
@ -724,7 +724,7 @@ func (c *Posv) Prepare(chain consensus.ChainReader, header *types.Header) error
|
|||
c.lock.RUnlock()
|
||||
}
|
||||
// Set the correct difficulty
|
||||
header.Difficulty = CalcDifficulty(snap, c.signer)
|
||||
header.Difficulty = big.NewInt(1)
|
||||
|
||||
// Ensure the extra data has all it's components
|
||||
if len(header.Extra) < extraVanity {
|
||||
|
|
|
|||
|
|
@ -828,7 +828,7 @@ func (pool *TxPool) promoteSpecialTx(addr common.Address, tx *types.Transaction)
|
|||
go func() {
|
||||
for _, btx := range broadcastTxs {
|
||||
pool.specialTxFeed.Send(TxPreEvent{btx})
|
||||
log.Debug("Pooled new special transaction", "hash", tx.Hash(), "from", addr, "to", tx.To(), "nonce", tx.Nonce())
|
||||
log.Trace("Pooled new special transaction", "hash", tx.Hash(), "from", addr, "to", tx.To(), "nonce", tx.Nonce())
|
||||
}
|
||||
}()
|
||||
return true, nil
|
||||
|
|
|
|||
|
|
@ -605,7 +605,7 @@ func (f *Fetcher) rescheduleComplete(complete *time.Timer) {
|
|||
func (f *Fetcher) enqueue(peer string, block *types.Block) {
|
||||
hash := block.Hash()
|
||||
if f.knowns.Contains(hash) {
|
||||
log.Debug("Discarded propagated block, knowns block", "peer", peer, "number", block.Number(), "hash", hash, "limit", blockLimit)
|
||||
log.Debug("Discarded propagated block, known block", "peer", peer, "number", block.Number(), "hash", hash, "limit", blockLimit)
|
||||
return
|
||||
}
|
||||
// Ensure the peer isn't DOSing us
|
||||
|
|
|
|||
|
|
@ -651,14 +651,17 @@ func (pm *ProtocolManager) handleMsg(p *peer) error {
|
|||
trueTD = new(big.Int).Sub(request.TD, request.Block.Difficulty())
|
||||
)
|
||||
// Update the peers total difficulty if better than the previous
|
||||
if _, td := p.Head(); trueTD.Cmp(td) > 0 {
|
||||
_, td := p.Head()
|
||||
currentBlock := pm.blockchain.CurrentBlock()
|
||||
currentTd := pm.blockchain.GetTd(currentBlock.Hash(), currentBlock.NumberU64())
|
||||
log.Debug("NewBlockMsg", "p", p, "number", request.Block.NumberU64(), "trueTD", trueTD, "td", td, "currentTd", currentTd)
|
||||
if trueTD.Cmp(td) > 0 {
|
||||
p.SetHead(trueHead, trueTD)
|
||||
|
||||
// Schedule a sync if above ours. Note, this will not fire a sync for a gap of
|
||||
// a singe block (as the true TD is below the propagated block), however this
|
||||
// scenario should easily be covered by the fetcher.
|
||||
currentBlock := pm.blockchain.CurrentBlock()
|
||||
if trueTD.Cmp(pm.blockchain.GetTd(currentBlock.Hash(), currentBlock.NumberU64())) > 0 {
|
||||
if trueTD.Cmp(currentTd) > 0 {
|
||||
go pm.synchronise(p)
|
||||
}
|
||||
}
|
||||
|
|
@ -739,7 +742,7 @@ func (pm *ProtocolManager) BroadcastSpecialTx(hash common.Hash, tx *types.Transa
|
|||
for _, peer := range peers {
|
||||
peer.SendSpecialTransactions(tx)
|
||||
}
|
||||
log.Debug("Broadcast special transaction", "hash", hash, "recipients", len(peers))
|
||||
log.Trace("Broadcast special transaction", "hash", hash, "recipients", len(peers))
|
||||
}
|
||||
|
||||
// Mined broadcast loop
|
||||
|
|
|
|||
|
|
@ -169,8 +169,8 @@ func (pm *ProtocolManager) synchronise(peer *peer) {
|
|||
// Make sure the peer's TD is higher than our own
|
||||
currentBlock := pm.blockchain.CurrentBlock()
|
||||
td := pm.blockchain.GetTd(currentBlock.Hash(), currentBlock.NumberU64())
|
||||
|
||||
pHead, pTd := peer.Head()
|
||||
log.Debug("ProtocolManager synchronise ", "p", peer, "pTd", pTd, "currentTd", td)
|
||||
if pTd.Cmp(td) <= 0 {
|
||||
return
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue