good morning!!!!

Skip to content
Snippets Groups Projects
Unverified Commit 89c30492 authored by Alex Sharov's avatar Alex Sharov Committed by GitHub
Browse files

limit amount of sentries in broadcasts (#3920)

* save

* save
parent 37f977fb
No related branches found
No related tags found
No related merge requests found
......@@ -3,6 +3,7 @@ package sentry
import (
"context"
"errors"
"math"
"math/big"
"strings"
"syscall"
......@@ -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() {
......@@ -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() {
......@@ -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:
......@@ -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() {
......
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