Giter Club home page Giter Club logo

orbit-db-control-center's Introduction

OrbitDB

Matrix npm (scoped) node-current (scoped)

OrbitDB is a serverless, distributed, peer-to-peer database. OrbitDB uses IPFS as its data storage and Libp2p Pubsub to automatically sync databases with peers. It's an eventually consistent database that uses Merkle-CRDTs for conflict-free database writes and merges making OrbitDB an excellent choice for p2p and decentralized apps, blockchain applications and local-first web applications.

OrbitDB provides various types of databases for different data models and use cases:

  • events: an immutable (append-only) log with traversable history. Useful for "latest N" use cases or as a message queue.
  • documents: a document database to which JSON documents can be stored and indexed by a specified key. Useful for building search indices or version controlling documents and data.
  • keyvalue: a key-value database just like your favourite key-value database.
  • keyvalue-indexed: key-value data indexed in a Level key-value database.

All databases are implemented on top of OrbitDB's OpLog, an immutable, cryptographically verifiable, operation-based conflict-free replicated data structure (CRDT) for distributed systems. OpLog is formalized in the paper Merkle-CRDTs. You can also easily extend OrbitDB by implementing and using a custom data model benefitting from the same properties as the default data models provided by the underlying Merkle-CRDTs.

This is the Javascript implementation and it works both in Browsers and Node.js with support for Linux, OS X, and Windows.

A Go implementation is developed and maintained by the Berty project at berty/go-orbit-db.

Installation

Install OrbitDB and its dependencies:

npm install @orbitdb/core helia

Browser <script> tag

OrbitDB can be loaded in the browser using the distributed js file with the <script/> tag. OrbitDB is the global namespace and all external functions are available via this namespace:

<script>/path/to/orbitdb.min.js</script>

Quick Start

If you want to get up and running with OrbitDB quickly, install and follow the instructions in the @orbitdb/quickstart module.

Usage

If you're using @orbitdb/core to develop browser or Node.js applications, use it as a module with the javascript instance of IPFS.

import { createHelia } from 'helia'
import { createOrbitDB } from '@orbitdb/core'
import { gossipsub } from "@chainsafe/libp2p-gossipsub";
import { identify } from "@libp2p/identify";
import { createLibp2p } from 'libp2p'

const Libp2pOptions = {
  services: {
    pubsub: gossipsub({
      // neccessary to run a single peer
      allowPublishToZeroTopicPeers: true
    }),
    identify: identify()
  }
}

;(async function () {
  const libp2p = await createLibp2p({ ...Libp2pOptions })
  const ipfs = await createHelia({libp2p})
  const orbitdb = await createOrbitDB({ ipfs })

  // Create / Open a database. Defaults to db type "events".
  const db = await orbitdb.open("hello")
  
  const address = db.address
  console.log(address)
  // "/orbitdb/zdpuAkstgbTVGHQmMi5TC84auhJ8rL5qoaNEtXo2d5PHXs2To"
  // The above address can be used on another peer to open the same database

  // Listen for updates from peers
  db.events.on("update", async entry => {
    console.log(entry)
    const all = await db.all()
    console.log(all)
  })

  // Add an entry
  const hash = await db.add("world")
  console.log(hash)

  // Query
  for await (const record of db.iterator()) {
    console.log(record)
  }
  
  await db.close()
  await orbitdb.stop()
  await ipfs.stop()
})()

To configure your IPFS instance for persistency and Libp2p to connect to peers, see Creating a Helia instance and the Default Libp2p Configurations in @orbitdb/quickstart for examples.

Documentation

Use the Getting Started guide for an initial introduction to OrbitDB.

You can find more advanced topics in our docs covering:

API

See https://api.orbitdb.org for the full API documentation.

Development

Run Tests

npm run test

Build

npm run build

Benchmark

node benchmarks/orbitdb-events.js

See benchmarks/ for more benchmarks.

API

To build the API documentation, run:

npm run build:docs

Documentation is output to ./docs/api.

Other implementations

If you know of any other repos that ought to be included in this section, please open a PR and add them.

Contributing

Take a look at our organization-wide Contributing Guide. You'll find most of your questions answered there.

If you want to code but don't know where to start, check out the issues labelled "help wanted".

Sponsors

The development of OrbitDB has been sponsored by:

If you want to sponsor developers to work on OrbitDB, please donate to our OrbitDB Open Collective or reach out to @haadcode.

License

MIT © 2015-2023 Protocol Labs Inc., Haja Networks Oy, OrbitDB Community

orbit-db-control-center's People

Contributors

aphelionz avatar haadcode avatar rigwild avatar tabcat avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

orbit-db-control-center's Issues

Not able to open Database

Unhandled Rejection (Error): 'options.create' set to 'false'. If you want to create a database, set 'options.create' to 'true'.

Im getting this unhandled rejection when attempting to open a db with address:
/orbitdb/zdpuApwoA95rK1fVFGrtRYTRSgUuDPSEAKho3zZ85VYNtiLjT/Users

Screenshot from 2021-12-03 16-48-36

No entries visible for remotely connected orbitdb

Context

I have an application with OrbitDB using a remote IPFS daemon (actually, all running on the same machine).

I changed your code a bit such that I can connect to that local IPFS peer, because I wasn't able to
open my databases using your demoed web version.

import IpfsClient from 'ipfs-http-client'

// ...

// Start OrbitDB
export const initOrbitDB = async () => {
  orbitdb = await OrbitDB.createInstance(IpfsClient('http://localhost:5001'))
  return orbitdb
}

I configured CORS for my IPFS peer, such that it works without issues

Actual Behavior

After these changes I was able to open the database, and as you can see they are correctly detected.

image

The issue is that, even having douments stored, no entries are shown, when added programmatically in my application.

image

Expected Behavior

When adding documents to the OrbitDB, they should appear in the Control Center


I'm not sure that this is an issue with your useful viewer, or something I forgot to do on my apps side. In my innocent understanding, I expect an implicit replication of the data. Maybe you can help me on this.

Thanks in advance

IPFS in CI

This passes CI but we still have an issue with IPFS:

  ●  Cannot log after tests are done. Did you forget to wait for something async in your test?
    Attempted to log "generating 2048-bit (rsa only) RSA keypair...".

      20 | }
      21 |
    > 22 | export const getAllDatabases = async () => {
         |          ^
      23 |   if (!programs && orbitdb) {
      24 |     // Load programs database
      25 |     programs = await orbitdb.feed('network.programs', {

      at console.log (node_modules/@jest/console/build/CustomConsole.js:185:10)
      at initPeerId (node_modules/ipfs-core/src/components/storage.js:176:3)
      at initRepo (node_modules/ipfs-core/src/components/storage.js:110:13)
      at loadRepo (node_modules/ipfs-core/src/components/storage.js:86:17)
      at Function.start (node_modules/ipfs-core/src/components/storage.js:54:41)
      at Object.create (node_modules/ipfs-core/src/components/index.js:223:21)
      at initIPFS (src/database/index.js:22:10)

(node:76) UnhandledPromiseRejectionWarning: Error: digest should be a Uint8Array
(Use `node --trace-warnings ...` to show where the warning was created)
(node:76) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 2)
(node:76) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

CircleCI received exit code 0

Originally posted by @aphelionz in #11 (comment)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.