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



推荐阅读
  • Webpack5内置处理图片资源的配置方法
    本文介绍了在Webpack5中处理图片资源的配置方法。在Webpack4中,我们需要使用file-loader和url-loader来处理图片资源,但是在Webpack5中,这两个Loader的功能已经被内置到Webpack中,我们只需要简单配置即可实现图片资源的处理。本文还介绍了一些常用的配置方法,如匹配不同类型的图片文件、设置输出路径等。通过本文的学习,读者可以快速掌握Webpack5处理图片资源的方法。 ... [详细]
  • 成功安装Sabayon Linux在thinkpad X60上的经验分享
    本文分享了作者在国庆期间在thinkpad X60上成功安装Sabayon Linux的经验。通过修改CHOST和执行emerge命令,作者顺利完成了安装过程。Sabayon Linux是一个基于Gentoo Linux的发行版,可以将电脑快速转变为一个功能强大的系统。除了作为一个live DVD使用外,Sabayon Linux还可以被安装在硬盘上,方便用户使用。 ... [详细]
  • SpringBoot整合SpringSecurity+JWT实现单点登录
    SpringBoot整合SpringSecurity+JWT实现单点登录,Go语言社区,Golang程序员人脉社 ... [详细]
  • node.jsurlsearchparamsAPI哎哎哎 ... [详细]
  • 本文讨论了在使用Git进行版本控制时,如何提供类似CVS中自动增加版本号的功能。作者介绍了Git中的其他版本表示方式,如git describe命令,并提供了使用这些表示方式来确定文件更新情况的示例。此外,文章还介绍了启用$Id:$功能的方法,并讨论了一些开发者在使用Git时的需求和使用场景。 ... [详细]
  • css div中文字位置_超赞的 CSS 阴影技巧与细节
    本文的题目是CSS阴影技巧与细节。CSS阴影,却不一定是box-shadow与filter:drop-shadow,为啥?因为使用其他属性 ... [详细]
  • Apple iPad:过渡设备还是平板电脑?
    I’vebeenagonizingoverwhethertopostaniPadarticle.Applecertainlydon’tneedmorepublicityandthe ... [详细]
  • Spring MVC定制用户登录注销实现示例
    这篇文章描述了如何实现对SpringMVCWeb应用程序的自定义用户访问(登录注销)。作为前提,建议读者阅读这篇文章,其中介 ... [详细]
  • 本文介绍了前端人员必须知道的三个问题,即前端都做哪些事、前端都需要哪些技术,以及前端的发展阶段。初级阶段包括HTML、CSS、JavaScript和jQuery的基础知识。进阶阶段涵盖了面向对象编程、响应式设计、Ajax、HTML5等新兴技术。高级阶段包括架构基础、模块化开发、预编译和前沿规范等内容。此外,还介绍了一些后端服务,如Node.js。 ... [详细]
  • Spring常用注解(绝对经典),全靠这份Java知识点PDF大全
    本文介绍了Spring常用注解和注入bean的注解,包括@Bean、@Autowired、@Inject等,同时提供了一个Java知识点PDF大全的资源链接。其中详细介绍了ColorFactoryBean的使用,以及@Autowired和@Inject的区别和用法。此外,还提到了@Required属性的配置和使用。 ... [详细]
  • 如何查询zone下的表的信息
    本文介绍了如何通过TcaplusDB知识库查询zone下的表的信息。包括请求地址、GET请求参数说明、返回参数说明等内容。通过curl方法发起请求,并提供了请求示例。 ... [详细]
  • 图像因存在错误而无法显示 ... [详细]
  • Gitlab接入公司内部单点登录的安装和配置教程
    本文介绍了如何将公司内部的Gitlab系统接入单点登录服务,并提供了安装和配置的详细教程。通过使用oauth2协议,将原有的各子系统的独立登录统一迁移至单点登录。文章包括Gitlab的安装环境、版本号、编辑配置文件的步骤,并解决了在迁移过程中可能遇到的问题。 ... [详细]
  • 语法必须遵守的语法推荐遵守语法不做要求文件格式文件应该使用Unicode(UTF-8)编码保存。同时不要使用字节序标记(BOM)。与UTF-16和 ... [详细]
  • 在给定置信度下,判断检测到给定值时所需要的样本量;也能计算在某样本量内能检测到给定效应值的概率功效是1-二类错误,1-β,看做真实效应发生的概率效应值是在备选或研究假设下效应的量对 ... [详细]
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社区 版权所有