Skip to content

Commit

Permalink
feat(p2p): channel recv rate limiting - continued
Browse files Browse the repository at this point in the history
  • Loading branch information
lklimek committed Feb 16, 2024
1 parent 623706e commit 54e00f7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
10 changes: 6 additions & 4 deletions internal/p2p/channel.go
Original file line number Diff line number Diff line change
Expand Up @@ -377,12 +377,14 @@ func (tci *throttledChannelIterator) Next(ctx context.Context) bool {
}
e := tci.innerIter.Envelope()
if tci.reportErr && e != nil {
tci.innerChan.SendError(ctx, PeerError{
msg := PeerError{
NodeID: e.From,
Err: ErrRecvRateLimitExceeded,
Fatal: false,
})

Fatal: true,
}
if err := tci.innerChan.SendError(ctx, msg); err != nil {
tci.logger.Error("error sending error message", "err", err, "msg", msg)
}
} else {
tci.logger.Trace("dropping message due to rate limit", "channel", tci.innerChan, "rate", tci.limiter.Limit())
}
Expand Down
4 changes: 2 additions & 2 deletions internal/p2p/channel_params.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ func ChannelDescriptors(cfg *config.Config) map[ChannelID]*ChannelDescriptor {
Name: "mempool",
SendRateLimit: 5, // TODO: make it configurable
SendRateBurst: 20, // TODO: make it configurable
RecvRateLimit: 1, // TODO: make it configurable
RecvRateBurst: 1, // TODO: make it configurable
RecvRateLimit: 10, // TODO: make it configurable
RecvRateBurst: 100, // TODO: make it configurable
RecvRateShouldErr: true, // TODO: make it configurable
EnqueueTimeout: 10 * time.Millisecond,
},
Expand Down

0 comments on commit 54e00f7

Please sign in to comment.