1.0.0 • Published 3 years ago

@dswarm/replicator v1.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

@dswarm/replicator

Replicate data structures easily using dSwarm

Install

npm install @dswarm/replicator

Usage

You data structure has to support a .replicate() stream, then you can replicate them using the dSwarm replicator.

const replicate = require('@dswarm/replicator')

const swarm = replicate(aDDatabase, {
  live: true // passed to .replicate
})

// swarm is a dSwarm instance that replicates the passed in instance

API

swarm = replicate(dataStructure, [options])

Options include

{
  bootstrap: [...], // optional set the DHT bootstrap servers
  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
}

License

MIT