Skip to content

Commit 8301f3b

Browse files
singlerrStefanBratanov
authored andcommitted
Apply InboundTrafficLimitHandler only if max bytes > 0
1 parent 3d4b05f commit 8301f3b

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

libp2p/src/main/java/io/libp2p/protocol/circuit/CircuitHopProtocol.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -315,11 +315,15 @@ public void onMessage(@NotNull Stream stream, Circuit.HopMessage msg) {
315315
new CircuitStopProtocol.StopRemover());
316316

317317
// connect these streams with time + bytes enforcement
318-
fromRequestor.pushHandler(new InboundTrafficLimitHandler(resv.maxBytes));
318+
if(resv.maxBytes > 0){
319+
fromRequestor.pushHandler(new InboundTrafficLimitHandler(resv.maxBytes));
320+
}
319321
fromRequestor.pushHandler(
320322
new TotalTimeoutHandler(
321323
Duration.of(resv.durationSeconds, ChronoUnit.SECONDS)));
322-
toTarget.pushHandler(new InboundTrafficLimitHandler(resv.maxBytes));
324+
if(resv.maxBytes > 0){
325+
toTarget.pushHandler(new InboundTrafficLimitHandler(resv.maxBytes));
326+
}
323327
toTarget.pushHandler(
324328
new TotalTimeoutHandler(
325329
Duration.of(resv.durationSeconds, ChronoUnit.SECONDS)));

0 commit comments

Comments
 (0)