Skip to content

Concurrent version history based on a Merkle-DAG on top of IPFS and IPLD

License

Notifications You must be signed in to change notification settings

ipfs-shipyard/js-ipfs-versidag

Repository files navigation

ipfs-versidag

NPM version Downloads Build Status Coverage Status Dependency status Dev Dependency status

Concurrent version history based on a Merkle-DAG on top of IPFS and IPLD.

This module wraps versidag and automatically configures readNode and writeNode to use IPFS and IPLD.

version + dag = versidag

Installation

$ npm install ipfs-versidag

You must also install ipfs as it is a peer dependency of this module.

Usage

import IPFS from 'ipfs';
import createIpfsVersidag from 'ipfs-versidag';

const ipfs = new IPFS();

ipfs.on('ready', async () => {
    const myVersidag = createIpfsVersidag({
        ipfs,
        tieBreaker: (node1, node2) => /* */,
    });

    const myVersidagA = await myVersidag.add('Hi', 1);
    const myVersidagB = await myVersidagA.add('Hello', 2);
    const myVersidagC = await myVersidagA.add('Hi World', 3);
    const myVersidagD = await myVersidagB.merge(myVersidagC.headCids, 'Hello World');

    const versions = await myVersidagD.resolve();
    // [
    //   { version: 'Hello World' },
    //   { version: 'Hi World', meta: 3 }
    //   { version: 'Hello', meta: 2 }
    //   { version: 'Hi', meta: 1 }
    // ]
});

You may use the IPLD explorer to inspect the Merkle DAG.

API

Please refer to the versidag API.

Tests

$ npm test
$ npm test -- --watch  # during development

License

Released under the MIT License.

About

Concurrent version history based on a Merkle-DAG on top of IPFS and IPLD

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published