Replicate data structures easily using hyperswarm
npm install @hyperswarm/replicator
You data structure has to support a .replicate() stream, then you can replicate them using the hyperswarm replicator.
const Replicator = require('@hyperswarm/replicator')
const r = new Replicator()
r.add(aHypercore, {
live: true // passed to .replicate
})
Make a new replicator. Options include:
{
bootstrap: [...], // optional set the DHT bootstrap servers
}
Add a hyper* data structure to replicate.
{
live: bool, // passed to .replicate
upload: bool, // passed to .replicate
download: bool, // passed to .replicate
encrypt: bool, // passed to .replicate
discoveryKey: <buf>, // optionally set your own discovery key
announce: true, // should the swarm announce you?
lookup: true, // should the swarm do lookups for you?
keyPair: { publicKey, secretKey }, // noise keypair used for the connection
onauthenticate (remotePublicKey, done) // the onauthenticate hook to verify remote key pairs
}
Promise resolves when the data structure has been fully added.
Remove a data structure from replication. Promise resolves when the data structure has been fully removed.
The associated hyperswarm instance.
Emitted when a remote asks for a discovery key of a data structure you are not currently replicating.
Easy "one off" replication of one or more data structures.
MIT