OverviewFilesCommitsIssuesDocsReleasesPeers

hyper-proto-peer commits / 61c01a3

0.3.134: get-state election carries presence attach/receive counts
Reads atproto-room 0.2.32 presenceDiag, so a split election shows whether presence attached at all. 180/180. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
61c01a315d5da3fb4c2b20cee5943b64ce875ac2
by plankatron <fleeky@gmail.com> · 2026-10-14T18:07:22.000Z

Changed files (3) +11 -2

lib/swarm-device.js +1 -1
……@@ -859,7 +859,7 @@ export class SwarmDevice {
859859 try {
860860 let netRev = null
861861 if (this.firehose) { const h = commitLine(Object.values(await this.sb.listNow(FIREHOSE_PREFIX)).filter((f) => f && f.rev)).head; netRev = h ? h.rev : null }
862 return { netRev, withHead: this.sb.signerState(undefined, netRev), noHead: this.sb.signerState() }
862 return { netRev, withHead: this.sb.signerState(undefined, netRev), noHead: this.sb.signerState(), presence: this.sb.presenceDiag ? this.sb.presenceDiag() : null }
863863 } catch { return null }
864864 })(),
865865 indexers: (this.sb.base && this.sb.base.linearizer && this.sb.base.linearizer.indexers) ? this.sb.base.linearizer.indexers.length : null,
package.json +1 -1
……@@ -1,6 +1,6 @@
11{
22 "name": "hyper-proto-peer",
3 "version": "0.3.133",
3 "version": "0.3.134",
44 "description": "Self-custody, P2P-native atproto peer \u2014 holds the user's key + content as Hypercores and authors+signs its own repo. The source of truth in the peer/bridge split (Model B); atproto-bridge projects it to bsky.",
55 "type": "module",
66 "main": "lib/peer.js",
test/swarm-device-is-signer.test.mjs +9 -0
……@@ -59,6 +59,15 @@ test('state() reports the election with and without the network head, and isSign
5959 t.alike(s.election.withHead.heads, { A: null, B: h.rev }, 'with each co-owner\'s known head')
6060})
6161
62test('state().election carries the substrate\'s presence attach/receive counts', async (t) => {
63 const sb = new MemKV()
64 const A = new SwarmDevice(sb, { did: DID, privateKey: KEY, self: 'A', firehose: true })
65 sb.signerState = () => ({ self: 'A', signer: 'A', effective: ['A'], holds: true, heads: {} })
66 sb.presenceDiag = () => ({ attached: 3, duplicate: 1, received: 0, peers: {} })
67 const s = await A.state()
68 t.alike(s.election.presence, { attached: 3, duplicate: 1, received: 0, peers: {} })
69})
70
6271test('a substrate with no election (single writer) signs — the same default as sign()', async (t) => {
6372 const A = new SwarmDevice(new MemKV(), { did: DID, privateKey: KEY, self: 'A', firehose: true })
6473 t.is(await A.isSigner(), true)