Skip to content

dwebprotocol/replicator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 

Repository files navigation

@hyperswarm/replicator

Replicate data structures easily using hyperswarm

Install

npm install @hyperswarm/replicator

Usage

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

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

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

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

API

swarm = replicate(dataStructure, [options])

Options include

{
  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

About

Replicates dDatabase-based abstractions easily using dWebSwarm

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%