• This repository has been archived on 30/Sep/2023
  • Stars
    star
    394
  • Rank 109,295 (Top 3 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created over 8 years ago
  • Updated almost 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Append-only log CRDT on IPFS

ipfs-log

npm CircleCI Status Gitter Matrix

An append-only log on IPFS.

ipfs-log is an immutable, operation-based conflict-free replicated data structure (CRDT) for distributed systems. It's an append-only log that can be used to model a mutable, shared state between peers in p2p applications.

Every entry in the log is saved in IPFS and each points to a hash of previous entry(ies) forming a graph. Logs can be forked and joined back together.

The module works in Node.js and Browsers.

           Log A                Log B
             |                    |
     logA.append("one")   logB.append("hello")
             |                    |
             v                    v
          +-----+             +-------+
          |"one"|             |"hello"|
          +-----+             +-------+
             |                    |
     logA.append("two")   logB.append("world")
             |                    |
             v                    v
       +-----------+       +---------------+
       |"one","two"|       |"hello","world"|
       +-----------+       +---------------+
             |                    |
             |                    |
       logA.join(logB) <----------+
             |
             v
+---------------------------+
|"one","hello","two","world"|
+---------------------------+

Table of Contents

Background

IPFS Log has a few use cases:

  • CRDTs
  • Database operations log
  • Feed of data
  • Track a version of a file
  • Messaging

It was originally created for, and currently used in, orbit-db - a distributed peer-to-peer database on IPFS.

Requirements

  • Node.js v8.6.0 or newer (uses ... spread syntax)
  • Preferably you should use an LTS version of node.js (even numbered 8, 10, etc)

Install

This project uses npm and nodejs.

npm install ipfs-log

Usage

See the API documentation and examples for more details.

Quick Start

Install dependencies:

npm install ipfs-log ipfs

Run a simple program:

// For js-ipfs >= 0.38

import from Log 'ipfs-log'
import IdentityProvider from 'orbit-db-identity-provider'
import * as IPFS from 'ipfs'

const start = async () => {
  const identity = await IdentityProvider.createIdentity({ id: "peerid" })
  const ipfs = await IPFS.create({ repo: "./path-for-js-ipfs-repo" })
  const log = new Log(ipfs, identity)

  await log.append({ some: "data" })
  await log.append("text")
  console.log(log.values.map((e) => e.payload))
}

start()

// [ { some: 'data' }, 'text' ]

Node.js

See examples for details.

If your platforms requires ES5-compatible JavaScript, there's a build in lib/es5/.

Browser

See examples/browser for details.

The distribution package for browsers is located in dist/ipfslog.min.js

If your platforms requires ES5-compatible JavaScript, there's a build in lib/es5/.

API

See API Documentation for full details.

Tests

Run all tests:

npm test

Run tests with js-ipfs only (default):

mocha

Run tests with go-ipfs only:

TEST=go mocha

Benchmarking

To use the benchmark runner:

node --expose-gc benchmarks/runner/index.js -r --grep append-stress --stress-limit Infinity

This will run the append-stress benchmarks until it is canceled. For more information, see the Benchmarking README.

Build

Run the following command before you commit.

make rebuild

This will ensure that dependencies and built files are all based on the current code base.

Benchmarks

There's a benchmark suite in benchmarks/ that can be run with:

node benchmarks/benchmark-append.js
node benchmarks/benchmark-join.js
node benchmarks/benchmark-expand.js

There's append and join benchmarks for browsers in benchmarks/browser/ which you can run by opening the .html files in your browser.

Contribute

If you find a bug or something is broken, let us know! PRs and issues are gladly accepted too. Take a look at the open issues, too, to see if there is anything that you could do or someone else has already done. Here are some things I know I need:

TODO

  • Support for payload encryption

License

MIT © 2016-2018 Protocol Labs Inc., 2016-2019 Haja Networks Oy

More Repositories

1

orbitdb

Peer-to-Peer Databases for the Decentralized Web
JavaScript
8,258
star
2

orbit

A distributed, serverless, peer-to-peer chat application on IPFS
1,637
star
3

orbit-web

Orbit Web Application
JavaScript
262
star
4

crdts

A library of Conflict-Free Replicated Data Types for JavaScript
JavaScript
211
star
5

field-manual

The Offical User's Guide to OrbitDB
JavaScript
210
star
6

awesome-orbitdb

Useful resources for using OrbitDB and building projects on it
134
star
7

welcome

☄️💫 The OrbitDB community and documentation repo
95
star
8

orbit-db-control-center

UI for managing OrbitDB databases
JavaScript
85
star
9

orbit-core

Orbit communication protocol and library
JavaScript
70
star
10

orbit-db-cli

CLI for orbit-db
JavaScript
61
star
11

orbit-textui

A prototype terminal client for Orbit
JavaScript
48
star
12

orbit-electron

Orbit Electron App
JavaScript
45
star
13

orbit-db-docstore

Document Store for orbit-db
JavaScript
40
star
14

orbit-db-store

Base class for orbit-db data stores
JavaScript
40
star
15

orbit-db-http-api

A HTTP API Server for the OrbitDB distributed peer-to-peer database
JavaScript
38
star
16

orbit-db-pinner

A pinning service for Orbitdb, a decentralized database based on IPFS.
JavaScript
35
star
17

py-orbit-db-http-client

A python client for the Orbitdb HTTP API
Python
33
star
18

orbit-db-identity-provider

Default identity provider for OrbitDB
JavaScript
32
star
19

orbitdb.org

The website for OrbitDB
HTML
32
star
20

orbit-db-eventstore

Append-Only Log database for orbit-db
JavaScript
30
star
21

go-orbit-db

Go implementation of OrbitDB.
Go
28
star
22

orbit-db-access-controllers

Access Controllers for OrbitDB
JavaScript
27
star
23

orbit-db-kvstore

Key-Value database for orbit-db
JavaScript
26
star
24

orbit-db-types

Unofficial orbit-db typings!
TypeScript
25
star
25

web3-workshop

A workshop showing how to build a basic app using OrbitDB
SCSS
25
star
26

repo-template

A template for creating new repositories in the @orbitdb organization
22
star
27

example-orbitdb-todomvc

TodoMVC with OrbitDB
JavaScript
22
star
28

orbit-db-pubsub

Message propagation module for orbit-db
JavaScript
19
star
29

orbit-db-feedstore

Log database for orbit-db
JavaScript
16
star
30

orbit-db-powergate-io

A bridge between OrbitDB and Powergate, which is itself a bridge between Filecoin and IPFS.
JavaScript
14
star
31

orbit-chat

Deprecated: Rewrite of orbit-web. Go to https://github.com/orbitdb/orbit-web
JavaScript
14
star
32

research

Decentralized Database Research
13
star
33

orbit-db-cache

Local cache for orbit-db
JavaScript
11
star
34

orbit-db-counterstore

Counters database for OrbitDB
JavaScript
10
star
35

orbit-db-keystore

A local key manager for OrbitDB
JavaScript
9
star
36

SCPs

Inbox for proposals to improve OrbitDB
HTML
9
star
37

opentelemetry-plugin-orbitdb

OpenTelemetry Plugin for OrbitDB
TypeScript
8
star
38

orbit-db-storage-adapter

A wrapper for abstract-leveldown compliant stores, used by OrbitDB
JavaScript
8
star
39

example-orbitdb-todomvc-updated

TodoMVC app using OrbitDB
JavaScript
7
star
40

orbit-db-io

Helper module used in OrbitDB to interface with storage layer
JavaScript
7
star
41

localstorage-level-migration

Move items from localstorage to leveldb
JavaScript
6
star
42

orbit-db-polkadot-iam

Identity Provider and Access Controller for Polkadot / Substrate based accounts
JavaScript
5
star
43

ipfs-post

POST prototype for IPFS
JavaScript
5
star
44

.github

Default Community documents
5
star
45

orbit-db-test-utils

Shared test utilities for OrbitDB-related projects
JavaScript
5
star
46

orbit-bot

Bot for Orbit communication network that caches messages
JavaScript
5
star
47

orbitdb-identity-provider-did

Create, sign and verify OrbitDB identities using Decentralized Identifiers (DIDs).
JavaScript
5
star
48

quickstart

A preconfigured instance which allows developers to "test drive" OrbitDB.
JavaScript
5
star
49

benchmark-runner

OrbitDB Benchmark Runner
JavaScript
4
star
50

orbitdb-orbit-crypto

Crypto primitives for Orbit
JavaScript
4
star
51

example-orbitdb-webpack

How to use OrbitDB JavaScript module with webpack
JavaScript
3
star
52

orbit-db-access-controller-store

Deprecated: OrbitDB Access Controller Store
JavaScript
3
star
53

spec

Specifications for implementing the OrbitDB System
3
star
54

logo

🌑 Orbit's brand files, formats and guidelines
2
star
55

orbit-db-community-stats

A script to get stats for the orbitdb GitHub organization
Python
2
star
56

eslint-config-orbitdb

Deprecated: Standard ESLint config for OrbitDB
JavaScript
2
star
57

orbitdb-identity-provider-ethereum

Provides creation and signing of identities using an Ethereum wallet.
JavaScript
2
star
58

examples

Implementing OrbitDB on various Javascript platforms.
JavaScript
2
star
59

orbit-db-http-api-bash-client

A HTTP API client for the OrbitDB distributed peer-to-peer database in bash
1
star