ipfs-observed-remove
[![CircleCI](https://circleci.com/gh/wehriam/ipfs-observed-remove.svg?style=svg)](https://circleci.com/gh/wehriam/ipfs-observed-remove) [![npm version](https://badge.fury.io/js/ipfs-observed-remove.svg)](http://badge.fury.io/js/ipfs-observed-remove) [![co
Last updated 4 months ago by wehriam .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install ipfs-observed-remove 
SYNC missed versions from official npm registry.

IPFS Observed-Remove Set and Map

CircleCI npm version codecov

Eventually-consistent, conflict-free replicated data types (CRDT) implemented using IPFS and native Map and Set objects.

This module and the IPFS PubSub system are experimental. If you encounter an issue, fork the repository, write tests demonstrating the issue, and create a pull request.

const ipfsAPI = require('ipfs-http-client');
const { IpfsObservedRemoveSet } = require('ipfs-observed-remove');

// IPFS nodes with PubSub enabled
const ipfs1 = ipfsAPI('/ip4/127.0.0.1/tcp/5001'); 
const ipfs2 = ipfsAPI('/ip4/127.0.0.1/tcp/5002');

const topic = "CRDT_SET";

const alice = new IpfsObservedRemoveSet(ipfs1, topic);
const bob = new IpfsObservedRemoveSet(ipfs2, topic);

alice.on('add', (value) => {
  console.log(value); // logs foo, bar
});

alice.add('foo');
bob.add('bar');

// Later

alice.has('bar'); // true
bob.has('foo'); // true
const ipfsAPI = require('ipfs-http-client');
const { IpfsObservedRemoveMap } = require('ipfs-observed-remove');

// IPFS nodes with PubSub enabled
const ipfs1 = ipfsAPI('/ip4/127.0.0.1/tcp/5001'); 
const ipfs2 = ipfsAPI('/ip4/127.0.0.1/tcp/5002');

const topic = "CRDT_MAP";

const alice = new IpfsObservedRemoveMap(ipfs1, topic);
const bob = new IpfsObservedRemoveMap(ipfs2, topic);

alice.on('set', (key, value) => {
  console.log(key, value); // logs [a, 1], [b, 2]
});

alice.set('a', 1);
bob.add('b', 2);

// Later

alice.get('b'); // 2
bob.get('a'); // 1

Install

yarn add ipfs-observed-remove

Set API

Table of Contents

constructor

Create an observed-remove CRDT.

Parameters

  • ipfs Object? Object implementing the core IPFS API, most likely a js-ipfs or ipfs-http-client object.
  • topic String? IPFS pubub topic to use in synchronizing the CRDT.
  • entries Iterable<V> Iterable of initial values (optional, default [])
  • options Object (optional, default {})
    • options.maxAge String Max age of insertion/deletion identifiers (optional, default 5000)
    • options.bufferPublishing String Interval by which to buffer 'publish' events (optional, default 20)

ipfsSync

Publish an IPFS hash of an array containing all of the object's insertions and deletions.

Returns Array<Array<any>>

dump

Return a sorted array containing all of the set's insertions and deletions.

getIpfsHash

Stores and returns an IPFS hash of the current insertions and deletions

Returns Promise<string>

ipfsPeerCount

Current number of IPFS pubsub peers.

Returns number

shutdown

Gracefully shutdown

Returns void

IpfsObservedRemoveSet#readyPromise

Resolves when IPFS topic subscriptions are confirmed.

Type: Promise<void>

Map API

Table of Contents

constructor

Create an observed-remove CRDT.

Parameters

  • ipfs Object? Object implementing the core IPFS API, most likely a js-ipfs or ipfs-http-client object.
  • topic String? IPFS pubub topic to use in synchronizing the CRDT.
  • entries Iterable<V> Iterable of initial values (optional, default [])
  • options Object (optional, default {})
    • options.maxAge String Max age of insertion/deletion identifiers (optional, default 5000)
    • options.bufferPublishing String Interval by which to buffer 'publish' events (optional, default 20)

ipfsSync

Publish an IPFS hash of an array containing all of the object's insertions and deletions.

Returns Array<Array<any>>

dump

Return a sorted array containing all of the set's insertions and deletions.

getIpfsHash

Stores and returns an IPFS hash of the current insertions and deletions

Returns Promise<string>

ipfsPeerCount

Current number of IPFS pubsub peers.

Returns number

shutdown

Gracefully shutdown

Returns void

IpfsObservedRemoveSet#readyPromise

Resolves when IPFS topic subscriptions are confirmed.

Type: Promise<void>

Current Tags

  • 2.2.31                                ...           latest (4 months ago)

56 Versions

  • 2.2.31                                ...           4 months ago
  • 2.2.30                                ...           4 months ago
  • 2.2.28                                ...           6 months ago
  • 2.2.27                                ...           6 months ago
  • 2.2.26                                ...           6 months ago
  • 2.2.25                                ...           6 months ago
  • 2.2.24                                ...           7 months ago
  • 2.2.23                                ...           9 months ago
  • 2.2.22                                ...           9 months ago
  • 2.2.20                                ...           9 months ago
  • 2.2.19                                ...           9 months ago
  • 2.2.18                                ...           9 months ago
  • 2.2.16                                ...           9 months ago
  • 2.2.13                                ...           9 months ago
  • 2.2.12                                ...           9 months ago
  • 2.2.11                                ...           9 months ago
  • 2.2.10                                ...           10 months ago
  • 2.2.9                                ...           10 months ago
  • 2.2.8                                ...           10 months ago
  • 2.2.7                                ...           a year ago
  • 2.2.6                                ...           a year ago
  • 2.2.5                                ...           a year ago
  • 2.2.4                                ...           a year ago
  • 2.2.3                                ...           a year ago
  • 2.2.2                                ...           a year ago
  • 2.0.6                                ...           2 years ago
  • 2.0.5                                ...           2 years ago
  • 2.0.4                                ...           2 years ago
  • 2.0.3                                ...           2 years ago
  • 2.0.1                                ...           2 years ago
  • 2.0.0                                ...           2 years ago
  • 1.3.15                                ...           2 years ago
  • 1.3.14                                ...           2 years ago
  • 1.3.13                                ...           2 years ago
  • 1.3.12                                ...           2 years ago
  • 1.3.11                                ...           2 years ago
  • 1.3.10                                ...           2 years ago
  • 1.3.9                                ...           3 years ago
  • 1.3.8                                ...           3 years ago
  • 1.3.7                                ...           3 years ago
  • 1.3.6                                ...           3 years ago
  • 1.3.5                                ...           3 years ago
  • 1.3.4                                ...           3 years ago
  • 1.3.3                                ...           3 years ago
  • 1.3.1                                ...           3 years ago
  • 1.3.0                                ...           3 years ago
  • 1.2.3                                ...           3 years ago
  • 1.2.2                                ...           3 years ago
  • 1.2.1                                ...           3 years ago
  • 1.2.0                                ...           3 years ago
  • 1.1.1                                ...           3 years ago
  • 1.1.0                                ...           3 years ago
  • 1.0.3                                ...           3 years ago
  • 1.0.2                                ...           3 years ago
  • 1.0.1                                ...           3 years ago
  • 1.0.0                                ...           3 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (8)
Dev Dependencies (27)

Copyright 2014 - 2016 © taobao.org |