mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 10:52:25 +00:00
eth: avoid potential division by 0
This commit is contained in:
parent
110edd67fe
commit
820baa91a3
1 changed files with 6 additions and 2 deletions
|
|
@ -616,9 +616,13 @@ func (h *handler) BroadcastTransactions(txs types.Transactions) {
|
||||||
annos = make(map[*ethPeer][]common.Hash) // Set peer->hash to announce
|
annos = make(map[*ethPeer][]common.Hash) // Set peer->hash to announce
|
||||||
)
|
)
|
||||||
// Broadcast transactions to a batch of peers not knowing about it
|
// Broadcast transactions to a batch of peers not knowing about it
|
||||||
|
direct := big.NewInt(int64(math.Sqrt(float64(h.peers.len())))) // Approximate number of peers to broadcast to
|
||||||
|
if direct.BitLen() == 0 {
|
||||||
|
direct = big.NewInt(1)
|
||||||
|
}
|
||||||
|
total := new(big.Int).Exp(direct, big.NewInt(2), nil) // Stabilise total peer count a bit based on sqrt peers
|
||||||
|
|
||||||
var (
|
var (
|
||||||
direct = big.NewInt(int64(math.Sqrt(float64(h.peers.len())))) // Approximate number of peers to broadcst to
|
|
||||||
total = new(big.Int).Exp(direct, big.NewInt(2), nil) // Stabilise total peer count a bit based on sqrt peers
|
|
||||||
signer = types.LatestSignerForChainID(h.chain.Config().ChainID) // Don't care about chain status, we ust need *a* sender
|
signer = types.LatestSignerForChainID(h.chain.Config().ChainID) // Don't care about chain status, we ust need *a* sender
|
||||||
hasher = sha3.NewLegacyKeccak256().(crypto.KeccakState)
|
hasher = sha3.NewLegacyKeccak256().(crypto.KeccakState)
|
||||||
hash = make([]byte, 32)
|
hash = make([]byte, 32)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue