Skip to content

Commit 592c4dc

Browse files
authored
Merge pull request #323 from f321x/warmup_budget
add warmup budget to PaddedRSTransport
2 parents f62f986 + 735513f commit 592c4dc

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/electrumx/server/transport.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ class PaddedRSTransport(RSTransport):
2424

2525
MIN_PACKET_SIZE = 1024
2626
WAIT_FOR_BUFFER_GROWTH_SECONDS = 1.0
27+
# amount of (unpadded) bytes sent instantly before beginning with polling.
28+
# This makes the initial handshake where a few small messages are exchanged faster.
29+
WARMUP_BUDGET_SIZE = 1024
2730

2831
session: Optional['RPCSessionWithTaskGroup']
2932

@@ -57,6 +60,7 @@ def _maybe_consume_sbuffer(self) -> None:
5760
self._force_send
5861
or len(buf) >= self.MIN_PACKET_SIZE
5962
or self._last_send + self.WAIT_FOR_BUFFER_GROWTH_SECONDS < time.monotonic()
63+
or self.session.send_size < self.WARMUP_BUDGET_SIZE
6064
):
6165
return
6266
assert buf[-2:] in (b"}\n", b"]\n"), f"unexpected json-rpc terminator: {buf[-2:]=!r}"

0 commit comments

Comments
 (0)