热门标签 | 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



推荐阅读
  • 合并列值-合并为一列问题需求:createtabletab(Aint,Bint,Cint)inserttabselect1,2,3unionallsel ... [详细]
  • Jquery 跨域问题
    为什么80%的码农都做不了架构师?JQuery1.2后getJSON方法支持跨域读取json数据,原理是利用一个叫做jsonp的概念。当然 ... [详细]
  • Iamtryingtomakeaclassthatwillreadatextfileofnamesintoanarray,thenreturnthatarra ... [详细]
  • 本文介绍了brain的意思、读音、翻译、用法、发音、词组、同反义词等内容,以及脑新东方在线英语词典的相关信息。还包括了brain的词汇搭配、形容词和名词的用法,以及与brain相关的短语和词组。此外,还介绍了与brain相关的医学术语和智囊团等相关内容。 ... [详细]
  • Android JSON基础,音视频开发进阶指南目录
    Array里面的对象数据是有序的,json字符串最外层是方括号的,方括号:[]解析jsonArray代码try{json字符串最外层是 ... [详细]
  • 单点登录原理及实现方案详解
    本文详细介绍了单点登录的原理及实现方案,其中包括共享Session的方式,以及基于Redis的Session共享方案。同时,还分享了作者在应用环境中所遇到的问题和经验,希望对读者有所帮助。 ... [详细]
  • JDK源码学习之HashTable(附带面试题)的学习笔记
    本文介绍了JDK源码学习之HashTable(附带面试题)的学习笔记,包括HashTable的定义、数据类型、与HashMap的关系和区别。文章提供了干货,并附带了其他相关主题的学习笔记。 ... [详细]
  • Spring常用注解(绝对经典),全靠这份Java知识点PDF大全
    本文介绍了Spring常用注解和注入bean的注解,包括@Bean、@Autowired、@Inject等,同时提供了一个Java知识点PDF大全的资源链接。其中详细介绍了ColorFactoryBean的使用,以及@Autowired和@Inject的区别和用法。此外,还提到了@Required属性的配置和使用。 ... [详细]
  • 如何查询zone下的表的信息
    本文介绍了如何通过TcaplusDB知识库查询zone下的表的信息。包括请求地址、GET请求参数说明、返回参数说明等内容。通过curl方法发起请求,并提供了请求示例。 ... [详细]
  • uniapp开发H5解决跨域问题的两种代理方法
    本文介绍了uniapp开发H5解决跨域问题的两种代理方法,分别是在manifest.json文件和vue.config.js文件中设置代理。通过设置代理根域名和配置路径别名,可以实现H5页面的跨域访问。同时还介绍了如何开启内网穿透,让外网的人可以访问到本地调试的H5页面。 ... [详细]
  • 本文介绍了如何使用JSONObiect和Gson相关方法实现json数据与kotlin对象的相互转换。首先解释了JSON的概念和数据格式,然后详细介绍了相关API,包括JSONObject和Gson的使用方法。接着讲解了如何将json格式的字符串转换为kotlin对象或List,以及如何将kotlin对象转换为json字符串。最后提到了使用Map封装json对象的特殊情况。文章还对JSON和XML进行了比较,指出了JSON的优势和缺点。 ... [详细]
  • MySQL语句大全:创建、授权、查询、修改等【MySQL】的使用方法详解
    本文详细介绍了MySQL语句的使用方法,包括创建用户、授权、查询、修改等操作。通过连接MySQL数据库,可以使用命令创建用户,并指定该用户在哪个主机上可以登录。同时,还可以设置用户的登录密码。通过本文,您可以全面了解MySQL语句的使用方法。 ... [详细]
  • 本文介绍了一个React Native新手在尝试将数据发布到服务器时遇到的问题,以及他的React Native代码和服务器端代码。他使用fetch方法将数据发送到服务器,但无法在服务器端读取/获取发布的数据。 ... [详细]
  • 本文介绍了在使用Laravel和sqlsrv连接到SQL Server 2016时,如何在插入查询中使用输出子句,并返回所需的值。同时讨论了使用CreatedOn字段返回最近创建的行的解决方法以及使用Eloquent模型创建后,值正确插入数据库但没有返回uniqueidentifier字段的问题。最后给出了一个示例代码。 ... [详细]
  • 本文讨论了在使用Git进行版本控制时,如何提供类似CVS中自动增加版本号的功能。作者介绍了Git中的其他版本表示方式,如git describe命令,并提供了使用这些表示方式来确定文件更新情况的示例。此外,文章还介绍了启用$Id:$功能的方法,并讨论了一些开发者在使用Git时的需求和使用场景。 ... [详细]
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社区 版权所有