swarm-super-peer
v0.1.3
Published
Server-side peer that seeds HLS segments over WebRTC
Readme
Swarm Super Peer
Server-side peer that downloads HLS segments over HTTP and seeds them to other peers over WebRTC. It never downloads data from the P2P network, acting purely as an uploader.
Running the super peer
Use the example script to start a peer that loads an HLS playlist and seeds its segments:
pnpm install
pnpm dlx tsx src/run-super-peer.tsRun the command from this package's directory. It uses the tsx runner to execute src/run-super-peer.ts.
Options
The super peer refreshes the HLS playlist every three seconds by default and
lets the core loader download new segments automatically via HTTP only. P2P
downloads are disabled; cached segments are uploaded to connected peers.
You can tweak the reload frequency and the number of concurrent HTTP downloads
with the reloadIntervalMs and simultaneousHttpDownloads options:
// run-super-peer.ts
import { createSuperPeer } from "swarm-super-peer";
await createSuperPeer({
streamUrl: "https://db691j6te7mt4.cloudfront.net/out/v1/f65bdb9d5ac1498ba700027b5ca8a383/index_5.m3u8",
swarmId: "swarm.video",
apiKey: "EXAMPLE14EXAMPLE32775aEXAMPLE94ac0530EXAMPLE7c02EXAMPLE",,
simultaneousHttpDownloads: 10,
});