@decentnetwork/peer 0.1.6 → 0.1.8
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.
- package/dist/peer.js +15 -0
- package/package.json +1 -1
package/dist/peer.js
CHANGED
|
@@ -1936,9 +1936,17 @@ export class Peer {
|
|
|
1936
1936
|
// stabilize self-announce in ~10s on a healthy network. Old serial
|
|
1937
1937
|
// walk took (per-node-timeout × N targets × 2 steps) ≈ 16 × 5s × 2
|
|
1938
1938
|
// = 160s worst case before a single isStored=2 response.
|
|
1939
|
+
// Reset counter at start so dhtHealth can distinguish "never ran" (-1)
|
|
1940
|
+
// from "ran but stored on 0 nodes" (0). The latter means our UDP
|
|
1941
|
+
// path is reaching bootstrap nodes but they're refusing to store
|
|
1942
|
+
// us — that's a wire-level problem (auth, network) we want to see.
|
|
1943
|
+
this.#lastSelfAnnounceStoredCount = 0;
|
|
1939
1944
|
for (let i = 0; i < candidates.length; i += SELF_ANNOUNCE_BATCH_SIZE) {
|
|
1940
1945
|
if (Date.now() >= deadlineMs) {
|
|
1941
1946
|
this.#debugLog("self announce stopped at deadline");
|
|
1947
|
+
// Even on early return, the count is live: storedNodes is what
|
|
1948
|
+
// we got so far.
|
|
1949
|
+
this.#lastSelfAnnounceStoredCount = storedNodes.length;
|
|
1942
1950
|
return storedNodes;
|
|
1943
1951
|
}
|
|
1944
1952
|
const wave = candidates.slice(i, i + SELF_ANNOUNCE_BATCH_SIZE);
|
|
@@ -1989,6 +1997,9 @@ export class Peer {
|
|
|
1989
1997
|
}
|
|
1990
1998
|
if (final.isStored === 2) {
|
|
1991
1999
|
storedNodes.push(c.node);
|
|
2000
|
+
// Keep dhtHealth.selfAnnounceStoredOn live within the loop,
|
|
2001
|
+
// not just at the end, so we see growth in real time.
|
|
2002
|
+
this.#lastSelfAnnounceStoredCount = storedNodes.length;
|
|
1992
2003
|
}
|
|
1993
2004
|
const discovered = parsePackedNodes(final.nodes);
|
|
1994
2005
|
if (discovered.length > 0) {
|
|
@@ -1996,6 +2007,10 @@ export class Peer {
|
|
|
1996
2007
|
}
|
|
1997
2008
|
}
|
|
1998
2009
|
}
|
|
2010
|
+
// Track the most recent acknowledged-storage count so dhtHealth()
|
|
2011
|
+
// can surface "DHT discovery layer alive but our announce isn't
|
|
2012
|
+
// landing on any node" vs the normal case.
|
|
2013
|
+
this.#lastSelfAnnounceStoredCount = storedNodes.length;
|
|
1999
2014
|
return storedNodes;
|
|
2000
2015
|
}
|
|
2001
2016
|
#ensureSelfAnnounceLoop() {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@decentnetwork/peer",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.8",
|
|
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",
|