@decentnetwork/peer 0.1.107 → 0.1.108

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -119,6 +119,8 @@ const LAN_STARTUP_QUEUE_MS = 500; // unmistakable raw queue spike; smaller app-l
119
119
  const LAN_STARTUP_HARD_QUEUE_MS = 2000; // one multi-second queue sample is unsafe
120
120
  const LAN_STARTUP_QUEUE_ROUNDS = 2; // tolerate one scheduler/session-handover outlier on LAN
121
121
  const LAN_STARTUP_KEEPUP = 0.70; // delivered goodput below 70% of pace means the receiver is no longer keeping up
122
+ const LAN_RECOVERY_GAIN = 1.20; // after a LAN overshoot drains, climb out of the 120KB/s floor quickly but smoothly
123
+ const LAN_RECOVERY_QUEUE_MS = 250; // only recover while queueing is clearly gone
122
124
  // Five 200 ms samples was still only about one Windows ACK scheduling cycle in
123
125
  // practice: a clean LAN (0% loss) exited STARTUP after ~3 MB and threw away a
124
126
  // healthy 2.3 MB/s probe. Require a few seconds of sustained under-delivery;
@@ -923,8 +925,18 @@ export class FileTransferManager {
923
925
  }
924
926
  else {
925
927
  // PROBE_BW cruise: one sample probes up, one drains, six cruise.
928
+ // If LAN STARTUP hit one real overshoot (e.g. a 1s ACK pause with
929
+ // high reported loss), the normal max-filter can be rebuilt from
930
+ // tiny post-drain samples and then takes tens of seconds to climb
931
+ // out of the 120KB/s floor. Once loss and queueing are gone, let
932
+ // a validated LAN recover toward its safe initial probe rate. The
933
+ // existing loss/queue brakes still stop a bad path immediately.
926
934
  const gain = PACE_CYCLE_GAINS[st.roundCount % PACE_CYCLE_GAINS.length];
927
- st.paceRateBps = Math.max(PACE_INIT_BPS * 0.5, st.btlBwBps * gain * lossMult);
935
+ const cruiseRate = Math.max(PACE_INIT_BPS * 0.5, st.btlBwBps * gain * lossMult);
936
+ const healthyLan = lanNow && st.lossEwma < 0.02 && rawQueue < LAN_RECOVERY_QUEUE_MS;
937
+ st.paceRateBps = healthyLan
938
+ ? Math.max(cruiseRate, Math.min(LAN_PACE_INIT_BPS, Math.max(st.paceRateBps * LAN_RECOVERY_GAIN, measuredRate * LAN_STARTUP_DELIVERY_GAIN)))
939
+ : cruiseRate;
928
940
  }
929
941
  // Hard safety cap: never pace faster than a full window drains in 1 RTT.
930
942
  if (st.minRttMs !== Infinity && st.minRttMs > 0) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@decentnetwork/peer",
3
- "version": "0.1.107",
3
+ "version": "0.1.108",
4
4
  "description": "Pure TypeScript port of Elastos Carrier (toxcore-derived) P2P messaging. DHT, onion routing, TCP relay, FlatBuffers app payloads, Express offline relay. Wire-compatible with iOS Beagle and the Carrier C SDK.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",