热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

OrbitDBPeer2PeerDatabaseusingCRDTs

2019独角兽企业重金招聘Python工程师标准Apeer-to-peerdatabaseforthedecentralizedwebOrbitDBisaserverless

2019独角兽企业重金招聘Python工程师标准>>> hot3.png

A peer-to-peer database for the decentralized web

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

Data in OrbitDB can be stored in a

  • Key-Value Store
  • Log Database (append-only log)
  • Feed (same as log database but entries can be removed)
  • Document Store (store indexed JSON documents)
  • Counters

This is the Javascript implementation and it works both in Node.js and Browsers.

To get started, try the OrbitDB CLI, read the Getting Started Guide or check Live demo 1, Live demo 2 or P2P TodoMVC app!

example1.png 68747470733a2f2f61736369696e656d612e6f72672f612f4a64546d6d6442435a61726b426b50716275656963774d72472e706e67

Table of Contents

  • Usage
  • API
  • Examples
  • Development
  • Background
  • Contributing
  • License

Usage

Read the GETTING STARTED guide for a more in-depth tutorial and to understand how OrbitDB works.

CLI

For the CLI tool to manage orbit-db database, see OrbitDB CLI.

It can be installed from Npm with:

npm install orbit-db-cli -g

As a library

Install dependencies:

npm install orbit-db ipfs

Use it as a module:

const IPFS = require('ipfs')
const OrbitDB = require('orbit-db')// OrbitDB uses Pubsub which is an experimental feature
// and need to be turned on manually.
// Note that these options need to be passed to IPFS in
// all examples even if not specfied so.
const ipfsOptions = {EXPERIMENTAL: {pubsub: true},
}// Create IPFS instance
const ipfs = new IPFS(ipfsOptions)ipfs.on('error', (e) => console.error(e))
ipfs.on('ready', async () => {// Create a databaseconst orbitdb = new OrbitDB(ipfs)const db = await orbitdb.log('database name')// Add an entry to the databaseconst hash = await db.add('hello world')// Get last 5 entriesconst latest = db.iterator({ limit: 5 }).collect()console.log(JSON.stringify(latest, null, 2))
})

For more details, see examples for kvstore, eventlog, feed, docstore and counter.

The minimum required version of Node.js is now 8.0.0. To use with older versions of Node.js, we provide an ES5-compatible build through the npm package, located in dist/es5/ when installed through npm.

API

See API documentation for the full documentation.

  • Getting Started
  • OrbitDB
    • keyvalue
    • log
    • feed
    • docstore
    • counter
    • common

Examples

Install dependencies

git clone https://github.com/orbitdb/orbit-db.git
cd orbit-db
npm install

You'll also need babel and webpack, if you don't have them installed already:

npm install --global babel-cli
npm install --global webpack

Browser example

npm run build
npm run examples:browser

example1.png

Check the code in examples/browser/browser.html and try the live example.

Node.js example

npm run examples:node

orbit-db-demo3.gif

Eventlog

See the code in examples/eventlog.js and run it with:

node examples/eventlog.js

More examples at examples.

Custom Store Types

You can add custom store types to OrbitDB:

// define custom store type
class CustomStore extends DocumentStore {constructor (ipfs, id, dbname, options) {super(ipfs, id, dbname, options)this._type = CustomStore.type}static get type () {return 'custom'}
}// add custom type to orbitdb
OrbitDB.addDatabaseType(CustomStore.type, CustomStore)// instantiate custom store
let orbitdb = new OrbitDB(ipfs, dbPath)
let store = orbitdb.create(name, CustomStore.type)

Development

Run Tests

npm test

Build

npm run build

Benchmark

node benchmarks/benchmark-add.js

See benchmarks/ for more benchmarks.

Logging

To enable OrbitDB's logging output, set a global ENV variable called LOG to debug,warn or error:

LOG=debug node

Background

Uses the following modules:

  • ipfs-log
  • crdts
  • orbit-db-cache
  • orbit-db-store
  • orbit-db-eventstore
  • orbit-db-feedstore
  • orbit-db-kvstore
  • orbit-db-docstore
  • orbit-db-counterstore
  • orbit-db-pubsub
  • orbit-db-keystore
  • ipfs
  • ipfs-pubub-room

To understand a little bit about the architecture, check out a visualization of the data flow at https://github.com/haadcode/proto2 or a live demo: http://celebdil.benet.ai:8080/ipfs/Qmezm7g8mBpWyuPk6D84CNcfLKJwU6mpXuEN5GJZNkX3XK/.

Contributing

We would be happy to accept PRs! If you want to work on something, it'd be good to talk beforehand to make sure nobody else is working on it. You can reach us on IRC #orbitdb on Freenode, or in the comments of the issues section.

A good place to start are the issues labelled "help wanted" or the project's status board.

Sponsors

The development of OrbitDB has been sponsored by:

  • Protocol Labs

If you want to sponsor developers to work on OrbitDB, please reach out to @haadcode.


转:https://my.oschina.net/u/2306127/blog/1613651



推荐阅读
  • 本文详细记录了在基于Debian的Deepin 20操作系统上安装MySQL 5.7的具体步骤,包括软件包的选择、依赖项的处理及远程访问权限的配置。 ... [详细]
  • 本文详细介绍如何使用Python进行配置文件的读写操作,涵盖常见的配置文件格式(如INI、JSON、TOML和YAML),并提供具体的代码示例。 ... [详细]
  • 使用 Azure Service Principal 和 Microsoft Graph API 获取 AAD 用户列表
    本文介绍了一段通用代码示例,该代码不仅能够操作 Azure Active Directory (AAD),还可以通过 Azure Service Principal 的授权访问和管理 Azure 订阅资源。Azure 的架构可以分为两个层级:AAD 和 Subscription。 ... [详细]
  • 深入解析Spring Cloud Ribbon负载均衡机制
    本文详细介绍了Spring Cloud中的Ribbon组件如何实现服务调用的负载均衡。通过分析其工作原理、源码结构及配置方式,帮助读者理解Ribbon在分布式系统中的重要作用。 ... [详细]
  • 本文详细介绍了Java编程语言中的核心概念和常见面试问题,包括集合类、数据结构、线程处理、Java虚拟机(JVM)、HTTP协议以及Git操作等方面的内容。通过深入分析每个主题,帮助读者更好地理解Java的关键特性和最佳实践。 ... [详细]
  • UNP 第9章:主机名与地址转换
    本章探讨了用于在主机名和数值地址之间进行转换的函数,如gethostbyname和gethostbyaddr。此外,还介绍了getservbyname和getservbyport函数,用于在服务器名和端口号之间进行转换。 ... [详细]
  • 本文详细介绍了Java中org.neo4j.helpers.collection.Iterators.single()方法的功能、使用场景及代码示例,帮助开发者更好地理解和应用该方法。 ... [详细]
  • 本文详细介绍了 GWT 中 PopupPanel 类的 onKeyDownPreview 方法,提供了多个代码示例及应用场景,帮助开发者更好地理解和使用该方法。 ... [详细]
  • 本文将介绍如何编写一些有趣的VBScript脚本,这些脚本可以在朋友之间进行无害的恶作剧。通过简单的代码示例,帮助您了解VBScript的基本语法和功能。 ... [详细]
  • Explore a common issue encountered when implementing an OAuth 1.0a API, specifically the inability to encode null objects and how to resolve it. ... [详细]
  • 技术分享:从动态网站提取站点密钥的解决方案
    本文探讨了如何从动态网站中提取站点密钥,特别是针对验证码(reCAPTCHA)的处理方法。通过结合Selenium和requests库,提供了详细的代码示例和优化建议。 ... [详细]
  • 本文详细介绍了如何在Linux系统上安装和配置Smokeping,以实现对网络链路质量的实时监控。通过详细的步骤和必要的依赖包安装,确保用户能够顺利完成部署并优化其网络性能监控。 ... [详细]
  • CentOS7源码编译安装MySQL5.6
    2019独角兽企业重金招聘Python工程师标准一、先在cmake官网下个最新的cmake源码包cmake官网:https:www.cmake.org如此时最新 ... [详细]
  • 深入理解 SQL 视图、存储过程与事务
    本文详细介绍了SQL中的视图、存储过程和事务的概念及应用。视图为用户提供了一种灵活的数据查询方式,存储过程则封装了复杂的SQL逻辑,而事务确保了数据库操作的完整性和一致性。 ... [详细]
  • MongoDB集群配置:副本集与分片详解
    本文详细介绍了如何在MongoDB中配置副本集(Replica Sets)和分片(Sharding),并提供了具体的步骤和命令,帮助读者理解并实现高可用性和水平扩展的MongoDB集群。 ... [详细]
author-avatar
mobiledu2502928043
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有