Skip to content

v0.2.0 — multi-peer enumeration + binary stream payloads

Choose a tag to compare

@proggeramlug proggeramlug released this 05 May 21:36
· 1 commit to main since this release

New — meaningful-implementation phase additions on top of the v0.1.x MVP:

  • endpointConnections(endpoint) — sync list of every active peer connection handle, for broadcast/fan-out
  • connNodeId(conn) — sync remote-peer node id lookup
  • streamWriteBuffer(stream, buffer) — binary-safe variant of streamWrite
  • streamReadToEndBuffer(stream, maxBytes) — binary-safe variant of streamReadToEnd

Together these unlock real-world P2P use cases: chat broadcast, file transfer, encrypted protocol payloads — all without UTF-8 round-tripping or external bookkeeping.

// Server: broadcast to every connected peer
for (const c of iroh.endpointConnections(ep)) {
  console.log("→", iroh.connNodeId(c));
  const stream = await iroh.openBi(c);
  await iroh.streamWriteBuffer(stream, payload);  // raw bytes
  await iroh.streamFinish(stream);
}

3 new unit tests for the conn-index logic.

Connection-event callbacks (endpoint.on('connection', cb)) deferred — polling via acceptOne + endpointConnections covers the broadcast use case today; event-driven listeners need a wrapper-specific GC scanner + main-thread event pump.