mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-25 14:16:44 +00:00
eth: update comment
This commit is contained in:
parent
fbe5401006
commit
8ce7159df4
1 changed files with 6 additions and 8 deletions
|
|
@ -682,14 +682,12 @@ func (st *blockRangeState) currentRange() eth.BlockRangeUpdatePacket {
|
||||||
return *st.next.Load()
|
return *st.next.Load()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Send the transaction (if it's small enough) directly to a subset of
|
// broadcastChoice implements a deterministic random choice of peers. This is designed
|
||||||
// the peers that have not received it yet, ensuring that the flow of
|
// specifically for choosing which peer receives a direct broadcast of a transaction.
|
||||||
// transactions is grouped by account to (try and) avoid nonce gaps.
|
|
||||||
//
|
//
|
||||||
// To do this, we hash the local node ID together with a peer's
|
// The choice is made based on the involved p2p node IDs and the transaction sender,
|
||||||
// node ID together with the transaction sender and broadcast if
|
// ensuring that the flow of transactions is grouped by account to (try and) avoid nonce
|
||||||
// `sha(self, peer, sender) mod peers < sqrt(peers)`.
|
// gaps.
|
||||||
|
|
||||||
type broadcastChoice struct {
|
type broadcastChoice struct {
|
||||||
self enode.ID
|
self enode.ID
|
||||||
key [16]byte
|
key [16]byte
|
||||||
|
|
@ -718,7 +716,7 @@ func newBroadcastChoice(self enode.ID, key [16]byte) *broadcastChoice {
|
||||||
// choosePeers selects the peers that will receive a direct transaction broadcast message.
|
// choosePeers selects the peers that will receive a direct transaction broadcast message.
|
||||||
// Note the return value will only stay valid until the next call to choosePeers.
|
// Note the return value will only stay valid until the next call to choosePeers.
|
||||||
func (bc *broadcastChoice) choosePeers(peers []*ethPeer, txSender common.Address) map[*ethPeer]struct{} {
|
func (bc *broadcastChoice) choosePeers(peers []*ethPeer, txSender common.Address) map[*ethPeer]struct{} {
|
||||||
// Compute scores.
|
// Compute randomized scores.
|
||||||
bc.tmp = slices.Grow(bc.tmp[:0], len(peers))[:len(peers)]
|
bc.tmp = slices.Grow(bc.tmp[:0], len(peers))[:len(peers)]
|
||||||
hash := siphash.New(bc.key[:])
|
hash := siphash.New(bc.key[:])
|
||||||
for i, peer := range peers {
|
for i, peer := range peers {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue