backoff on sync and reduce starting multiplier

This commit is contained in:
Maycon Santos
2025-05-08 11:30:41 +02:00
parent 3e963ffeba
commit 1a12100790
2 changed files with 3 additions and 1 deletions

View File

@@ -202,7 +202,7 @@ func BuildManager(
if err != nil {
initialInterval = 1
} else {
initialInterval = int64(interval) * 10
initialInterval = int64(interval) * 2
go func() {
time.Sleep(30 * time.Second)
am.updateAccountPeersBufferInterval.Store(int64(time.Duration(interval) * time.Millisecond))

View File

@@ -163,6 +163,8 @@ func getRealIP(ctx context.Context) net.IP {
// notifies the connected peer of any updates (e.g. new peers under the same account)
func (s *GRPCServer) Sync(req *proto.EncryptedMessage, srv proto.ManagementService_SyncServer) error {
if !s.syncLimiter.Allow() {
time.Sleep(time.Second + (time.Millisecond * time.Duration(rand.IntN(20)*100)))
log.Warnf("sync rate limit exceeded for peer %s", req.WgPubKey)
return status.Errorf(codes.Internal, "temp rate limit reached")
}