Skip to content

Commit

Permalink
limit amount of sentries in broadcasts (#3920)
Browse files Browse the repository at this point in the history
* save

* save
  • Loading branch information
AskAlexSharov authored Apr 20, 2022
1 parent 37f977f commit 89c3049
Showing 1 changed file with 25 additions and 4 deletions.
29 changes: 25 additions & 4 deletions cmd/sentry/sentry/broadcast.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package sentry
import (
"context"
"errors"
"math"
"math/big"
"strings"
"syscall"
Expand Down Expand Up @@ -41,10 +42,15 @@ func (cs *ControlServerImpl) PropagateNewBlockHashes(ctx context.Context, announ
return
}
var req66 *proto_sentry.OutboundMessageData
for _, sentry := range cs.sentries {
// Send the block to a subset of our peers
sendToAmount := int(math.Sqrt(float64(len(cs.sentries))))
for i, sentry := range cs.sentries {
if !sentry.Ready() {
continue
}
if i > sendToAmount { //TODO: send to random sentries, not just to fi
break
}

switch sentry.Protocol() {

Expand Down Expand Up @@ -77,10 +83,15 @@ func (cs *ControlServerImpl) BroadcastNewBlock(ctx context.Context, block *types
log.Error("broadcastNewBlock", "err", err)
}
var req66 *proto_sentry.SendMessageToRandomPeersRequest
for _, sentry := range cs.sentries {
// Send the block to a subset of our peers
sendToAmount := int(math.Sqrt(float64(len(cs.sentries))))
for i, sentry := range cs.sentries {
if !sentry.Ready() {
continue
}
if i > sendToAmount { //TODO: send to random sentries, not just to fi
break
}

switch sentry.Protocol() {

Expand Down Expand Up @@ -131,10 +142,15 @@ func (cs *ControlServerImpl) BroadcastLocalPooledTxs(ctx context.Context, txs []
log.Error("BroadcastLocalPooledTxs", "err", err)
}
var req66 *proto_sentry.OutboundMessageData
for _, sentry := range cs.sentries {
// Send the block to a subset of our peers
sendToAmount := int(math.Sqrt(float64(len(cs.sentries))))
for i, sentry := range cs.sentries {
if !sentry.Ready() {
continue
}
if i > sendToAmount { //TODO: send to random sentries, not just to fi
break
}

switch sentry.Protocol() {
case eth.ETH66:
Expand Down Expand Up @@ -185,10 +201,15 @@ func (cs *ControlServerImpl) BroadcastRemotePooledTxs(ctx context.Context, txs [
log.Error("BroadcastRemotePooledTxs", "err", err)
}
var req66 *proto_sentry.SendMessageToRandomPeersRequest
for _, sentry := range cs.sentries {
// Send the block to a subset of our peers
sendToAmount := int(math.Sqrt(float64(len(cs.sentries))))
for i, sentry := range cs.sentries {
if !sentry.Ready() {
continue
}
if i > sendToAmount { //TODO: send to random sentries, not just to fi
break
}

switch sentry.Protocol() {

Expand Down

0 comments on commit 89c3049

Please sign in to comment.