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
$ npm install ipfs-versidag
You must also install ipfs
as it is a peer dependency of this module.
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.
Please refer to the versidag API.
$ npm test
$ npm test -- --watch # during development
Released under the MIT License.