peer-crdt-ipfs
peer-crdt-ipfs
npm i peer-crdt-ipfs
peer-crdt-ipfs

peer-crdt-ipfs

peer-crdt network and store over IPFS

by ipfs-shipyard

0.4.0 (see all)License:MITTypeScript:Not Found
npm i peer-crdt-ipfs
Readme

peer-crdt-ipfs

IPFS network and storage adapter for peer-crdt.

Install

$ npm install ipfs peer-crdt peer-crdt-ipfs

Setup

const IPFS = require('ipfs')
const PeerCRDT = require('peer-crdt')
const PeerCrdtIpfs = require('peer-crdt-ipfs')

// Create an IPFS node
ipfs = new IPFS({
  EXPERIMENTAL: {
    pubsub: true
  }
})

const encrypt = async (value) => {
  return await somehowEncrypt(value)
}

const decrypt = async (buffer) => {
  return await somehowDecrypt(buffer)
}

const options = {
  encrypt,
  decrypt
}

// Create a peer-crdt-ifps config object:
const peerCrdtIpfs = PeerCrdtIpfs(ipfs)

// Use it to configure peer-crdt
const CRDT = PeerCRDT
  .defaults(peerCrdtIpfs)
  .defaults(options)

// Create and use a CRDT at will
const crdt = CRDT.create(type, id)
// ...

peer-crdt API docs are here

Options

The constructor exposed in peer-crdt-ipfs accepts, as the second argument, an object with the following options (defaults in parenthesis):

  • encrypt: an async function that accepts a value and resolves to a buffer.
  • decrypt: inverse function of the above: an async function that accepts a buffer and resolves to a value.
  • minBroadcastInterval (1000)
  • maxBroadcastInterval (5000)
  • totalNetworkBroadcastInterval (1000)
  • dag - object with:
    • format ('dag-cbor')
    • hashAlg ('sha2-256')
  • maxAncestorsBroadcast (10)
  • debounceSetHeadMS (500)

License

MIT

Downloads/wk

4

GitHub Stars

20

LAST COMMIT

5yrs ago

MAINTAINERS

1

CONTRIBUTORS

1

OPEN ISSUES

2

OPEN PRs

1
VersionTagPublished
0.4.0
latest
5yrs ago
No alternatives found
No tutorials found
Add a tutorial
No dependencies found

Rate & Review

100
No reviews found
Be the first to rate