@decentnetwork/peer 0.1.110 → 0.1.111

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.
@@ -785,12 +785,14 @@ export class FileTransferManager {
785
785
  // One paced round completed (the timed frontier byte's ack landed).
786
786
  const rtt = nowT - st.probeSentMs;
787
787
  st.probeOffset = -1;
788
+ const pathKindAtProbe = this.pathKind(friendId);
788
789
  // A single very-low sample can be a batched/late ACK that makes a probe
789
790
  // look newer than it is. But several consecutive low samples mean the
790
- // path genuinely improved (most importantly tcp-relay LAN UDP). The
791
- // old code rejected every such sample against the permanently-high srtt,
792
- // so startup stayed pinned near 120 KB/s forever. Promote a stable lower
793
- // RTT after three samples and rebase srtt/RTprop to the new path.
791
+ // path genuinely improved when we are moving onto a validated LAN path.
792
+ // Do NOT do this on public UDP-direct: cross-border ACK compression can
793
+ // produce several falsely-low samples, and rebasing RTprop there shrinks
794
+ // the BDP window to the floor, collapsing a good remote transfer to
795
+ // tens of KB/s.
794
796
  const lowSample = st.srttMs > 0 && rtt > 0 && rtt < st.srttMs * 0.4;
795
797
  if (lowSample) {
796
798
  st.lowRttCount++;
@@ -800,7 +802,7 @@ export class FileTransferManager {
800
802
  st.lowRttCount = 0;
801
803
  st.lowRttMinMs = Infinity;
802
804
  }
803
- const promoteLowPath = lowSample && st.lowRttCount >= 3;
805
+ const promoteLowPath = pathKindAtProbe === "lan" && lowSample && st.lowRttCount >= 3;
804
806
  const acceptedRtt = promoteLowPath ? st.lowRttMinMs : rtt;
805
807
  if (promoteLowPath) {
806
808
  st.srttMs = acceptedRtt;
@@ -823,7 +825,7 @@ export class FileTransferManager {
823
825
  const roundRate = ((st.acked - st.rateMarkAcked) * 1000) / sampleMs;
824
826
  st.rateMarkMs = nowT;
825
827
  st.rateMarkAcked = st.acked;
826
- const pathKind = this.pathKind(friendId);
828
+ const pathKind = pathKindAtProbe;
827
829
  const lanNow = pathKind === "lan";
828
830
  const udpDirectNow = pathKind === "udp-direct";
829
831
  // On a paced LAN flow, sustainable delivery cannot suddenly be
@@ -996,6 +998,7 @@ export class FileTransferManager {
996
998
  ` pace=${Math.round(st.paceRateBps)}Bps bw=${Math.round(st.btlBwBps)}Bps` +
997
999
  ` cwnd=${st.cwnd} phase=${st.bbrPhase} slow=${st.fullBwRounds}` +
998
1000
  ` loss=${(st.lossEwma * 100).toFixed(1)}% rounds=${st.roundCount}` +
1001
+ ` path=${pathKindAtProbe}` +
999
1002
  ` lanNow=${st.dbgLanNow} lanPath=${st.lanPath ? 1 : 0}` +
1000
1003
  ` sampleMs=${st.dbgSampleMs} roundRate=${st.dbgRoundRate}` +
1001
1004
  ` measuredRate=${st.dbgMeasuredRate} rawQueue=${st.dbgRawQueue}` +
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@decentnetwork/peer",
3
- "version": "0.1.110",
3
+ "version": "0.1.111",
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",