mirror of
https://github.com/orbitdb/orbitdb.git
synced 2025-05-19 21:36:37 +00:00
Merge branch 'master' into update-peer-exchanged
This commit is contained in:
commit
f876360e59
16
API.md
16
API.md
@ -100,7 +100,7 @@ const db = await orbitdb.keyvalue('profile')
|
|||||||
|
|
||||||
Before starting, you should know that OrbitDB has different types of databases. Each one satisfies a different purpose. The databases that you can create are:
|
Before starting, you should know that OrbitDB has different types of databases. Each one satisfies a different purpose. The databases that you can create are:
|
||||||
|
|
||||||
* [log](https://github.com/orbitdb/orbit-db/blob/master/API.md#orbitdblognameaddress): an imutable (write only) log database. Useful for transactions lists.
|
* [log](https://github.com/orbitdb/orbit-db/blob/master/API.md#orbitdblognameaddress): an immutable (write only) log database. Useful for transactions lists.
|
||||||
* [feed](https://github.com/orbitdb/orbit-db/blob/master/API.md#orbitdbfeednameaddress): a mutable log database. Useful for blog comments.
|
* [feed](https://github.com/orbitdb/orbit-db/blob/master/API.md#orbitdbfeednameaddress): a mutable log database. Useful for blog comments.
|
||||||
* [keyvalue](https://github.com/orbitdb/orbit-db/blob/master/API.md#orbitdbkeyvaluenameaddress): Useful for loading data from keywords or an id.
|
* [keyvalue](https://github.com/orbitdb/orbit-db/blob/master/API.md#orbitdbkeyvaluenameaddress): Useful for loading data from keywords or an id.
|
||||||
* [docs](https://github.com/orbitdb/orbit-db/blob/master/API.md#orbitdbdocsnameaddress-options): a JSON documents database. Useful for user data or other structured data.
|
* [docs](https://github.com/orbitdb/orbit-db/blob/master/API.md#orbitdbdocsnameaddress-options): a JSON documents database. Useful for user data or other structured data.
|
||||||
@ -116,6 +116,8 @@ Returns a `Promise` that resolves to [a database instance](#store-api). `name` (
|
|||||||
|
|
||||||
- `overwrite` (boolean): Overwrite an existing database (Default: `false`)
|
- `overwrite` (boolean): Overwrite an existing database (Default: `false`)
|
||||||
- `replicate` (boolean): Replicate the database with peers, requires IPFS PubSub. (Default: `true`)
|
- `replicate` (boolean): Replicate the database with peers, requires IPFS PubSub. (Default: `true`)
|
||||||
|
- `meta` (object): An optional object in [database manifest](https://github.com/orbitdb/orbit-db/blob/master/GUIDE.md#address). Immutably stores any JSON-serializable value. Readable via `db.options.meta`. Default: `undefined`.
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
const db = await orbitdb.create('user.posts', 'eventlog', {
|
const db = await orbitdb.create('user.posts', 'eventlog', {
|
||||||
accessController: {
|
accessController: {
|
||||||
@ -125,7 +127,10 @@ const db = await orbitdb.create('user.posts', 'eventlog', {
|
|||||||
// Give access to the second peer
|
// Give access to the second peer
|
||||||
'042c07044e7ea51a489c02854db5e09f0191690dc59db0afd95328c9db614a2976e088cab7c86d7e48183191258fc59dc699653508ce25bf0369d67f33d5d77839'
|
'042c07044e7ea51a489c02854db5e09f0191690dc59db0afd95328c9db614a2976e088cab7c86d7e48183191258fc59dc699653508ce25bf0369d67f33d5d77839'
|
||||||
]
|
]
|
||||||
}
|
},
|
||||||
|
overwrite: true,
|
||||||
|
replicate: false,
|
||||||
|
meta: { hello: 'meta hello' }
|
||||||
})
|
})
|
||||||
// db created & opened
|
// db created & opened
|
||||||
```
|
```
|
||||||
@ -222,6 +227,13 @@ Deletes the `Object` associated with `key`. Returns a `Promise` that resolves to
|
|||||||
// QmbYHhnXEdmdfUDzZKeEg7HyG2f8veaF2wBrYFcSHJ3mvd
|
// QmbYHhnXEdmdfUDzZKeEg7HyG2f8veaF2wBrYFcSHJ3mvd
|
||||||
```
|
```
|
||||||
|
|
||||||
|
#### all
|
||||||
|
Returns an `Object` with the contents of all entries in the index.
|
||||||
|
```javascript
|
||||||
|
const value = db.all
|
||||||
|
// { hello: { name: 'Friend' } }
|
||||||
|
```
|
||||||
|
|
||||||
### orbitdb.kvstore(name|address)
|
### orbitdb.kvstore(name|address)
|
||||||
|
|
||||||
Alias for [`orbitdb.keyvalue()`](#orbitdbkeyvaluenameaddress)
|
Alias for [`orbitdb.keyvalue()`](#orbitdbkeyvaluenameaddress)
|
||||||
|
57
CHANGELOG.md
57
CHANGELOG.md
@ -2,6 +2,63 @@
|
|||||||
|
|
||||||
Note: OrbitDB follows [semver](https://semver.org/). We are currently in alpha: backwards-incompatible changes may occur in minor releases.
|
Note: OrbitDB follows [semver](https://semver.org/). We are currently in alpha: backwards-incompatible changes may occur in minor releases.
|
||||||
|
|
||||||
|
## v0.24.1
|
||||||
|
|
||||||
|
### JS-IPFS 0.44 Support
|
||||||
|
Until now the newest versions of js-ipfs were not supported. This was primarly because of js-ipfs api's move to async iteration starting in version 0.41. Now js-ipfs versions 0.41-0.44 are supported.
|
||||||
|
|
||||||
|
Relevant PRs:
|
||||||
|
- https://github.com/orbitdb/orbit-db-store/pull/86
|
||||||
|
- https://github.com/orbitdb/orbit-db/pull/782
|
||||||
|
|
||||||
|
### Store Operation Queue
|
||||||
|
All included stores (and any store extending orbit-db-store v3.3.0+) now queues operations. Any update sent to a store is executed sequentially and the store's close method now awaits for the queue to empty.
|
||||||
|
|
||||||
|
Relevant PRs:
|
||||||
|
- https://github.com/orbitdb/orbit-db-store/pull/85
|
||||||
|
- https://github.com/orbitdb/orbit-db-store/pull/91
|
||||||
|
|
||||||
|
### Docstore putAll Operation
|
||||||
|
A new method was added to the docstore named 'putAll'. This method allows for multiple keys to be set in the docstore in one oplog entry. This comes with some significant [performance benefits](https://gist.github.com/phillmac/155ed1eb232e75fda4a793e7672460fd). Something to note is any nodes running an older version of the docstore will ignore any changes made by putAll operations.
|
||||||
|
|
||||||
|
Relevant PRs:
|
||||||
|
- https://github.com/orbitdb/orbit-db-docstore/pull/36
|
||||||
|
|
||||||
|
### Oplog Events
|
||||||
|
It is now possible to listen for specific store operations as they are added to the store. To learn more about how to use this you can review the [documentation](https://github.com/orbitdb/orbit-db-store#events) and look at event `log.op.${operation}`.
|
||||||
|
|
||||||
|
Relevant PRs:
|
||||||
|
- https://github.com/orbitdb/orbit-db-store/pull/87
|
||||||
|
|
||||||
|
### orbit-db tests
|
||||||
|
Tests now use [orbit-db-test-utils](https://github.com/orbitdb/orbit-db-test-utils) package to deduplicate test utilities. It had already been used in most subpackages like [orbit-db-store](https://github.com/orbitdb/orbit-db-store) but now it's used in the [orbit-db](https://github.com/orbitdb/orbit-db) repo!
|
||||||
|
|
||||||
|
Relevant PRs:
|
||||||
|
- https://github.com/orbitdb/orbit-db-test-utils/pull/11
|
||||||
|
- https://github.com/orbitdb/orbit-db/pull/794
|
||||||
|
|
||||||
|
### orbit-db-store sync method
|
||||||
|
A method on orbit-db-store named sync is now an async method and only resolves after oplog heads have been added.
|
||||||
|
|
||||||
|
Relevant PRs:
|
||||||
|
- https://github.com/orbitdb/orbit-db-store/pull/38
|
||||||
|
- https://github.com/orbitdb/orbit-db-store/pull/84
|
||||||
|
|
||||||
|
### Electron Renderer FS Shim
|
||||||
|
Fixes a bug related to the native filesystem when used in electron.
|
||||||
|
|
||||||
|
Relevant PRs:
|
||||||
|
- https://github.com/orbitdb/orbit-db/pull/783
|
||||||
|
- https://github.com/orbitdb/orbit-db/pull/795
|
||||||
|
|
||||||
|
### Re-exports
|
||||||
|
Now import AccessControllers, Identities, and/or Keystore modules from OrbitDB with object destructuring like so:
|
||||||
|
|
||||||
|
`const { AccessControllers, Identities, Keystore } = require('orbit-db')`
|
||||||
|
|
||||||
|
Relevant PRs:
|
||||||
|
- https://github.com/orbitdb/orbit-db/pull/785
|
||||||
|
|
||||||
## v0.23.0
|
## v0.23.0
|
||||||
|
|
||||||
### Performance Improvements
|
### Performance Improvements
|
||||||
|
6
FAQ.md
6
FAQ.md
@ -43,9 +43,9 @@ In short: it can't be assumed that data has been replicated to the network after
|
|||||||
|
|
||||||
### Does OrbitDB already support pinning when using js-ipfs ?
|
### Does OrbitDB already support pinning when using js-ipfs ?
|
||||||
|
|
||||||
Currently [js-ipfs](https://github.com/ipfs/js-ipfs) doesn't have GC, so nothing gets removed meaning everything is pinned by default.
|
Currently [js-ipfs](https://github.com/ipfs/js-ipfs) supports `ipfs.repo.gc()` but it's yet not run on any sort of schedule, so nothing gets removed from a `js-ipfs` node and therefore an OrbitDB database.
|
||||||
|
|
||||||
However, this will change in the future as js-ipfs gets GC and we want to make sure that OrbitDB is actually persisting everything (by default), so some work on pinning needs to happen. If you're using OrbitDB with go-ipfs (through js-ipfs-api), then GC happens and data may not be persisted anymore after a time. This is a known issue and we're planning to implement actual pinning (from IPFS perspective) soon.
|
However, this will change in the future as js-ipfs schedules GC and we want to make sure that OrbitDB is actually persisting everything (by default), so [some work on pinning needs to happen](https://github.com/ipfs/js-ipfs/issues/2650). If you're using OrbitDB with go-ipfs (through js-ipfs-api), and GC happens and data may not be persisted anymore. Once the pinning performance is fixed we will implement pinning-by-default in [`orbit-db-io`](https://github.com/orbitdb/orbit-db-io).
|
||||||
|
|
||||||
### Does orbit have a shared feed between peers where multiple peers can append to the same feed?
|
### Does orbit have a shared feed between peers where multiple peers can append to the same feed?
|
||||||
|
|
||||||
@ -79,7 +79,7 @@ To allow specific keys to write to the database, pass the keys as strings like s
|
|||||||
|
|
||||||
`orbitdb.feed('name', { accessController: { write ['key1', 'key2'] }}) // keys cannot be revoked`
|
`orbitdb.feed('name', { accessController: { write ['key1', 'key2'] }}) // keys cannot be revoked`
|
||||||
|
|
||||||
Allows anyone to write to the db. If you specify keys, the process involves granting and revoking keys. Granting is doable, but revokation is a harder and is being worked on by multiple parties, without a solution.
|
Allows anyone to write to the db. If you specify keys, the process involves granting and revoking keys. Granting is doable, but revocation is a harder and is being worked on by multiple parties, without a solution.
|
||||||
|
|
||||||
If you want to encrypt the keys or content, it's easier with a single user. If you want to use encryption with multiwriters, that's another bag which also hasn't been solved.
|
If you want to encrypt the keys or content, it's easier with a single user. If you want to use encryption with multiwriters, that's another bag which also hasn't been solved.
|
||||||
|
|
||||||
|
5
GUIDE.md
5
GUIDE.md
@ -10,6 +10,7 @@ This guide is still being worked on and we would love to get [feedback and sugge
|
|||||||
|
|
||||||
- [Background](#background)
|
- [Background](#background)
|
||||||
- [Install](#install)
|
- [Install](#install)
|
||||||
|
- [API](#api)
|
||||||
- [Setup](#setup)
|
- [Setup](#setup)
|
||||||
- [Create a database](#create-a-database)
|
- [Create a database](#create-a-database)
|
||||||
* [Address](#address)
|
* [Address](#address)
|
||||||
@ -48,6 +49,10 @@ Install [orbit-db](https://github.com/orbitdb/orbit-db) and [ipfs](https://www.n
|
|||||||
npm install orbit-db ipfs
|
npm install orbit-db ipfs
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## API
|
||||||
|
|
||||||
|
See [API.md](https://github.com/orbitdb/orbit-db/blob/master/API.md) for the full documentation.
|
||||||
|
|
||||||
## Setup
|
## Setup
|
||||||
|
|
||||||
Require OrbitDB and IPFS in your program and create the instances:
|
Require OrbitDB and IPFS in your program and create the instances:
|
||||||
|
2
Makefile
2
Makefile
@ -14,7 +14,7 @@ build: test
|
|||||||
cp node_modules/ipfs/dist/index.min.js examples/browser/lib/ipfs.min.js
|
cp node_modules/ipfs/dist/index.min.js examples/browser/lib/ipfs.min.js
|
||||||
cp dist/orbitdb.js examples/browser/lib/orbitdb.js
|
cp dist/orbitdb.js examples/browser/lib/orbitdb.js
|
||||||
cp dist/orbitdb.js.map examples/browser/lib/orbitdb.js.map
|
cp dist/orbitdb.js.map examples/browser/lib/orbitdb.js.map
|
||||||
cp node_modules/ipfs/dist/index.js examples/browser/lib/ipfs.js
|
cp node_modules/ipfs/dist/index.min.js examples/browser/lib/ipfs.js
|
||||||
@echo "Build success!"
|
@echo "Build success!"
|
||||||
@echo "Output: 'dist/', 'examples/browser/'"
|
@echo "Output: 'dist/', 'examples/browser/'"
|
||||||
|
|
||||||
|
100
README.md
100
README.md
@ -4,7 +4,7 @@
|
|||||||
<img src="images/orbit_db_logo_color.jpg" width="256" />
|
<img src="images/orbit_db_logo_color.jpg" width="256" />
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
[](https://gitter.im/orbitdb/Lobby) [](https://riot.permaweb.io/#/room/#orbitdb:permaweb.io) [](https://discord.gg/v3RNE3M) [](https://circleci.com/gh/orbitdb/orbit-db) [](https://www.npmjs.com/package/orbit-db) [](https://www.npmjs.com/package/orbit-db)
|
[](https://gitter.im/orbitdb/Lobby) [](https://riot.im/app/#/room/#orbit-db:matrix.org) [](https://discord.gg/v3RNE3M) [](https://circleci.com/gh/orbitdb/orbit-db) [](https://www.npmjs.com/package/orbit-db) [](https://www.npmjs.com/package/orbit-db)
|
||||||
|
|
||||||
OrbitDB is a **serverless, distributed, peer-to-peer database**. OrbitDB uses [IPFS](https://ipfs.io) as its data storage and [IPFS Pubsub](https://github.com/ipfs/go-ipfs/blob/master/core/commands/pubsub.go#L23) to automatically sync databases with peers. It's an eventually consistent database that uses [CRDTs](https://en.wikipedia.org/wiki/Conflict-free_replicated_data_type) for conflict-free database merges making OrbitDB an excellent choice for decentralized apps (dApps), blockchain applications and offline-first web applications.
|
OrbitDB is a **serverless, distributed, peer-to-peer database**. OrbitDB uses [IPFS](https://ipfs.io) as its data storage and [IPFS Pubsub](https://github.com/ipfs/go-ipfs/blob/master/core/commands/pubsub.go#L23) to automatically sync databases with peers. It's an eventually consistent database that uses [CRDTs](https://en.wikipedia.org/wiki/Conflict-free_replicated_data_type) for conflict-free database merges making OrbitDB an excellent choice for decentralized apps (dApps), blockchain applications and offline-first web applications.
|
||||||
|
|
||||||
@ -27,7 +27,7 @@ Status: **in active development**
|
|||||||
|
|
||||||
***NOTE!*** *OrbitDB is **alpha-stage** software. It means OrbitDB hasn't been security audited and programming APIs and data formats can still change. We encourage you to [reach out to the maintainers](https://gitter.im/orbitdb/Lobby) if you plan to use OrbitDB in mission critical systems.*
|
***NOTE!*** *OrbitDB is **alpha-stage** software. It means OrbitDB hasn't been security audited and programming APIs and data formats can still change. We encourage you to [reach out to the maintainers](https://gitter.im/orbitdb/Lobby) if you plan to use OrbitDB in mission critical systems.*
|
||||||
|
|
||||||
This is the Javascript implementation and it works both in **Browsers** and **Node.js** with support for Linux and OS X (Windows is not supported yet). The minimum required version of Node.js is now 8.6.0 due to the usage of `...` spread syntax. LTS versions (even numbered versions 8, 10, etc) are preferred.
|
This is the Javascript implementation and it works both in **Browsers** and **Node.js** with support for Linux and OS X and Windows. The minimum required version of Node.js is now 8.6.0 due to the usage of `...` spread syntax. LTS versions (even numbered versions 8, 10, etc) are preferred.
|
||||||
|
|
||||||
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.
|
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.
|
||||||
|
|
||||||
@ -40,6 +40,7 @@ We also have regular community calls, which we announce in the issues in [the @o
|
|||||||
|
|
||||||
- [Usage](#usage)
|
- [Usage](#usage)
|
||||||
* [CLI](#cli)
|
* [CLI](#cli)
|
||||||
|
* [Database browser UI](#database-browser-ui)
|
||||||
* [Module with IPFS Instance](#module-with-ipfs-instance)
|
* [Module with IPFS Instance](#module-with-ipfs-instance)
|
||||||
* [Module with IPFS Daemon](#module-with-ipfs-daemon)
|
* [Module with IPFS Daemon](#module-with-ipfs-daemon)
|
||||||
- [API](#api)
|
- [API](#api)
|
||||||
@ -79,6 +80,18 @@ It can be installed from npm with:
|
|||||||
npm install orbit-db-cli -g
|
npm install orbit-db-cli -g
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Database browser UI
|
||||||
|
|
||||||
|
OrbitDB databases can easily be managed using a web UI, see **[OrbitDB Control Center](https://github.com/orbitdb/orbit-db-control-center)**.
|
||||||
|
|
||||||
|
Install and run it locally:
|
||||||
|
|
||||||
|
```
|
||||||
|
git clone https://github.com/orbitdb/orbit-db-control-center.git
|
||||||
|
cd orbit-db-control-center/
|
||||||
|
npm i && npm start
|
||||||
|
```
|
||||||
|
|
||||||
### Module with IPFS Instance
|
### Module with IPFS Instance
|
||||||
|
|
||||||
If you're using `orbit-db` to develop **browser** or **Node.js** applications, use it as a module with the javascript instance of IPFS
|
If you're using `orbit-db` to develop **browser** or **Node.js** applications, use it as a module with the javascript instance of IPFS
|
||||||
@ -93,51 +106,84 @@ npm install orbit-db ipfs
|
|||||||
const IPFS = require('ipfs')
|
const IPFS = require('ipfs')
|
||||||
const OrbitDB = require('orbit-db')
|
const OrbitDB = require('orbit-db')
|
||||||
|
|
||||||
// Create IPFS instance
|
|
||||||
|
|
||||||
// For js-ipfs >= 0.38
|
// For js-ipfs >= 0.38
|
||||||
const ipfs = new IPFS()
|
|
||||||
|
|
||||||
// For js-ipfs < 0.38
|
// Create IPFS instance
|
||||||
const ipfsOptions = {
|
const initIPFSInstance = async () => {
|
||||||
EXPERIMENTAL: {
|
return await IPFS.create({ repo: "./path-for-js-ipfs-repo" });
|
||||||
pubsub: true
|
};
|
||||||
}
|
|
||||||
}
|
|
||||||
const ipfs = new IPFS(ipfsOptions)
|
|
||||||
|
|
||||||
ipfs.on('error', (e) => console.error(e))
|
initIPFSInstance().then(async ipfs => {
|
||||||
ipfs.on('ready', async () => {
|
const orbitdb = await OrbitDB.createInstance(ipfs);
|
||||||
const orbitdb = await OrbitDB.createInstance(ipfs)
|
|
||||||
|
|
||||||
// Create / Open a database
|
// Create / Open a database
|
||||||
const db = await orbitdb.log('hello')
|
const db = await orbitdb.log("hello");
|
||||||
await db.load()
|
await db.load();
|
||||||
|
|
||||||
// Listen for updates from peers
|
// Listen for updates from peers
|
||||||
db.events.on('replicated', (address) => {
|
db.events.on("replicated", address => {
|
||||||
console.log(db.iterator({ limit: -1 }).collect())
|
console.log(db.iterator({ limit: -1 }).collect());
|
||||||
})
|
});
|
||||||
|
|
||||||
// Add an entry
|
// Add an entry
|
||||||
const hash = await db.add('world')
|
const hash = await db.add("world");
|
||||||
console.log(hash)
|
console.log(hash);
|
||||||
|
|
||||||
// Query
|
// Query
|
||||||
const result = db.iterator({ limit: -1 }).collect()
|
const result = db.iterator({ limit: -1 }).collect();
|
||||||
console.log(JSON.stringify(result, null, 2))
|
console.log(JSON.stringify(result, null, 2));
|
||||||
})
|
});
|
||||||
|
|
||||||
|
|
||||||
|
// For js-ipfs < 0.38
|
||||||
|
|
||||||
|
// Create IPFS instance
|
||||||
|
const ipfsOptions = {
|
||||||
|
EXPERIMENTAL: {
|
||||||
|
pubsub: true
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
ipfs = new IPFS(ipfsOptions);
|
||||||
|
|
||||||
|
initIPFSInstance().then(ipfs => {
|
||||||
|
ipfs.on("error", e => console.error(e));
|
||||||
|
ipfs.on("ready", async () => {
|
||||||
|
const orbitdb = await OrbitDB.createInstance(ipfs);
|
||||||
|
|
||||||
|
// Create / Open a database
|
||||||
|
const db = await orbitdb.log("hello");
|
||||||
|
await db.load();
|
||||||
|
|
||||||
|
// Listen for updates from peers
|
||||||
|
db.events.on("replicated", address => {
|
||||||
|
console.log(db.iterator({ limit: -1 }).collect());
|
||||||
|
});
|
||||||
|
|
||||||
|
// Add an entry
|
||||||
|
const hash = await db.add("world");
|
||||||
|
console.log(hash);
|
||||||
|
|
||||||
|
// Query
|
||||||
|
const result = db.iterator({ limit: -1 }).collect();
|
||||||
|
console.log(JSON.stringify(result, null, 2));
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
### Module with IPFS Daemon
|
### Module with IPFS Daemon
|
||||||
Alternatively, you can use [ipfs-api](https://npmjs.org/package/ipfs-api) to use `orbit-db` with a locally running IPFS daemon. Use this method if you're using `orbitd-db` to develop **backend** or **desktop** applications, eg. with [Electron](https://electron.atom.io).
|
|
||||||
|
Alternatively, you can use [ipfs-http-client](https://www.npmjs.com/package/ipfs-http-client) to use `orbit-db` with a locally running IPFS daemon. Use this method if you're using `orbitd-db` to develop **backend** or **desktop** applications, eg. with [Electron](https://electron.atom.io).
|
||||||
|
|
||||||
Install dependencies:
|
Install dependencies:
|
||||||
|
|
||||||
```
|
```
|
||||||
npm install orbit-db ipfs-http-client
|
npm install orbit-db ipfs-http-client@41.0.1
|
||||||
```
|
```
|
||||||
|
|
||||||
|
**Note:** need to use v41.0.1 until support for modern JS API is added in [orbit-db#767](https://github.com/orbitdb/orbit-db/pull/767).
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
const IpfsClient = require('ipfs-http-client')
|
const IpfsClient = require('ipfs-http-client')
|
||||||
const OrbitDB = require('orbit-db')
|
const OrbitDB = require('orbit-db')
|
||||||
|
39087
package-lock.json
generated
39087
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
25
package.json
25
package.json
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "orbit-db",
|
"name": "orbit-db",
|
||||||
"version": "0.23.1",
|
"version": "0.24.1",
|
||||||
"description": "Distributed p2p database on IPFS",
|
"description": "Distributed p2p database on IPFS",
|
||||||
"author": "Haad",
|
"author": "Haad",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
@ -21,17 +21,17 @@
|
|||||||
"multihashes": "^0.4.12",
|
"multihashes": "^0.4.12",
|
||||||
"orbit-db-access-controllers": "~0.2.2",
|
"orbit-db-access-controllers": "~0.2.2",
|
||||||
"orbit-db-cache": "~0.3.0",
|
"orbit-db-cache": "~0.3.0",
|
||||||
"orbit-db-counterstore": "~1.7.0",
|
"orbit-db-counterstore": "~1.9.0",
|
||||||
"orbit-db-docstore": "~1.7.0",
|
"orbit-db-docstore": "~1.9.0",
|
||||||
"orbit-db-eventstore": "~1.7.0",
|
"orbit-db-eventstore": "~1.9.0",
|
||||||
"orbit-db-feedstore": "~1.7.0",
|
"orbit-db-feedstore": "~1.9.0",
|
||||||
"orbit-db-identity-provider": "~0.3.0",
|
"orbit-db-identity-provider": "~0.3.0",
|
||||||
"orbit-db-io": "~0.2.0",
|
"orbit-db-io": "~0.2.0",
|
||||||
"orbit-db-keystore": "~0.3.0",
|
"orbit-db-keystore": "~0.3.0",
|
||||||
"orbit-db-kvstore": "~1.7.0",
|
"orbit-db-kvstore": "~1.9.0",
|
||||||
"orbit-db-pubsub": "~0.5.5",
|
"orbit-db-pubsub": "~0.5.5",
|
||||||
"orbit-db-storage-adapter": "~0.5.3",
|
"orbit-db-storage-adapter": "~0.5.3",
|
||||||
"orbit-db-store": "git://github.com/orbitdb/orbit-db-store.git#3860443bf4f0fefaee9bd31d181a1a891afcba22"
|
"orbit-db-store": "~3.3.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"adm-zip": "^0.4.13",
|
"adm-zip": "^0.4.13",
|
||||||
@ -45,15 +45,11 @@
|
|||||||
"cross-env": "^6.0.3",
|
"cross-env": "^6.0.3",
|
||||||
"datastore-level": "~0.14.0",
|
"datastore-level": "~0.14.0",
|
||||||
"fs-extra": "^7.0.1",
|
"fs-extra": "^7.0.1",
|
||||||
"go-ipfs-dep": "~0.4.20",
|
|
||||||
"ipfs": "~0.40.0",
|
|
||||||
"ipfs-http-client": "~37.0.1",
|
|
||||||
"ipfs-repo": "~0.30.1",
|
|
||||||
"ipfsd-ctl": "~0.42.3",
|
|
||||||
"localstorage-level-migration": "~0.1.0",
|
"localstorage-level-migration": "~0.1.0",
|
||||||
"markdown-toc": "^1.2.0",
|
"markdown-toc": "^1.2.0",
|
||||||
"mkdirp": "^0.5.1",
|
"mkdirp": "^0.5.1",
|
||||||
"mocha": "^5.2.0",
|
"mocha": "^5.2.0",
|
||||||
|
"orbit-db-test-utils": "^0.9.4",
|
||||||
"p-each-series": "^1.0.0",
|
"p-each-series": "^1.0.0",
|
||||||
"p-map": "^1.2.0",
|
"p-map": "^1.2.0",
|
||||||
"p-map-series": "^1.0.0",
|
"p-map-series": "^1.0.0",
|
||||||
@ -76,7 +72,7 @@
|
|||||||
"examples:browser-windows": "start examples/browser/browser.html",
|
"examples:browser-windows": "start examples/browser/browser.html",
|
||||||
"lint:docs": "remark -qf -u validate-links .",
|
"lint:docs": "remark -qf -u validate-links .",
|
||||||
"test:all": "npm run test:browser-multiple-tabs && npm run test",
|
"test:all": "npm run test:browser-multiple-tabs && npm run test",
|
||||||
"test": "cross-env TEST=all mocha",
|
"test": "cross-env TEST=js mocha && cross-env TEST=go mocha;",
|
||||||
"test:browser-multiple-tabs": "npm run build:dist && cpy dist/orbitdb.min.js ./test/browser --rename=orbitdb.js && cpy node_modules/ipfs/dist/index.js ./test/browser --rename=ipfs.js && cpy node_modules/orbit-db-identity-provider/dist/index-browser.min.js ./test/browser --rename=identities.js && cpy node_modules/ipfs-log/dist/ipfslog.min.js ./test/browser && mocha ./test/browser/concurrent.spec.js",
|
"test:browser-multiple-tabs": "npm run build:dist && cpy dist/orbitdb.min.js ./test/browser --rename=orbitdb.js && cpy node_modules/ipfs/dist/index.js ./test/browser --rename=ipfs.js && cpy node_modules/orbit-db-identity-provider/dist/index-browser.min.js ./test/browser --rename=identities.js && cpy node_modules/ipfs-log/dist/ipfslog.min.js ./test/browser && mocha ./test/browser/concurrent.spec.js",
|
||||||
"build": "npm run build:es5 && npm run build:debug && npm run build:dist && npm run build:examples && npm run build:docs/toc",
|
"build": "npm run build:es5 && npm run build:debug && npm run build:dist && npm run build:examples && npm run build:docs/toc",
|
||||||
"build:examples": "webpack --config conf/webpack.example.config.js --sort-modules-by size",
|
"build:examples": "webpack --config conf/webpack.example.config.js --sort-modules-by size",
|
||||||
@ -85,6 +81,9 @@
|
|||||||
"build:docs/toc": "markdown-toc --no-first1 -i README.md && markdown-toc --no-first1 -i API.md && markdown-toc --no-first1 -i GUIDE.md && markdown-toc --no-first1 -i CHANGELOG.md && markdown-toc --no-first1 -i FAQ.md ",
|
"build:docs/toc": "markdown-toc --no-first1 -i README.md && markdown-toc --no-first1 -i API.md && markdown-toc --no-first1 -i GUIDE.md && markdown-toc --no-first1 -i CHANGELOG.md && markdown-toc --no-first1 -i FAQ.md ",
|
||||||
"build:es5": "babel src --out-dir ./dist/es5/ --presets babel-preset-env --plugins babel-plugin-transform-runtime"
|
"build:es5": "babel src --out-dir ./dist/es5/ --presets babel-preset-env --plugins babel-plugin-transform-runtime"
|
||||||
},
|
},
|
||||||
|
"go-ipfs": {
|
||||||
|
"version": "v0.5.1"
|
||||||
|
},
|
||||||
"standard": {
|
"standard": {
|
||||||
"env": "mocha",
|
"env": "mocha",
|
||||||
"ignore": [
|
"ignore": [
|
||||||
|
@ -519,4 +519,8 @@ class OrbitDB {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
OrbitDB.prototype.AccessControllers = AccessControllers
|
||||||
|
OrbitDB.prototype.Identities = Identities
|
||||||
|
OrbitDB.prototype.Keystore = Keystore
|
||||||
|
|
||||||
module.exports = OrbitDB
|
module.exports = OrbitDB
|
||||||
|
@ -1,5 +1,17 @@
|
|||||||
/* eslint-disable */
|
/* eslint-disable */
|
||||||
const fs = (typeof window === 'object' || typeof self === 'object') ? null
|
// adapted from https://github.com/cheton/is-electron - (c) Cheton Wu
|
||||||
: eval('require("fs")')
|
const isElectron = () => {
|
||||||
|
if (typeof window !== 'undefined' && typeof window.process === 'object') {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
if (typeof process !== 'undefined' && typeof process.versions === 'object' && !!process.versions.electron) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
const fs = (!isElectron() && (typeof window === 'object' || typeof self === 'object')) ? null : eval('require("fs")')
|
||||||
|
|
||||||
module.exports = fs
|
module.exports = fs
|
||||||
|
@ -22,16 +22,29 @@
|
|||||||
</div>
|
</div>
|
||||||
<!-- </div> -->
|
<!-- </div> -->
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
const randStr = () => Math.random().toString(36).substring(6)
|
document.addEventListener('DOMContentLoaded', async () => {
|
||||||
const ipfs = new Ipfs({
|
const randStr = () => Math.random().toString(36).substring(6)
|
||||||
repo: './odb/',
|
const ipfs = await Ipfs.create({
|
||||||
EXPERIMENTAL: {
|
repo: './odb/'
|
||||||
pubsub: true
|
})
|
||||||
},
|
|
||||||
preload: { enabled: false },
|
const identity = await Identities.createIdentity({ id: 'A'})
|
||||||
config: {
|
const orbitdb = await OrbitDB.createInstance(ipfs, { identity })
|
||||||
Bootstrap: [ ]
|
const consistentLog = await orbitdb.log('concurrent', { syncLocal: true, sortFn: Log.Sorting.SortByEntryHash })
|
||||||
}
|
const inconsistentLog = await orbitdb.log('concurrent2')
|
||||||
|
|
||||||
|
window.consistentLog = consistentLog
|
||||||
|
window.inconsistentLog = inconsistentLog
|
||||||
|
|
||||||
|
waitForOpenDB.innerHTML = consistentLog.address.toString() + ' + ' + inconsistentLog.address.toString()
|
||||||
|
await consistentLog.load()
|
||||||
|
await inconsistentLog.load()
|
||||||
|
|
||||||
|
addData.addEventListener('click', async event => {
|
||||||
|
const data = randStr()
|
||||||
|
await consistentLog.add(data)
|
||||||
|
await inconsistentLog.add(data)
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
async function getConsistentLogLength () {
|
async function getConsistentLogLength () {
|
||||||
@ -63,32 +76,6 @@
|
|||||||
await window.inconsistentLog.load()
|
await window.inconsistentLog.load()
|
||||||
}
|
}
|
||||||
|
|
||||||
ipfs.on('ready', async () => {
|
|
||||||
const identity = await Identities.createIdentity({ id: 'A'})
|
|
||||||
const orbitdb = await OrbitDB.createInstance(ipfs, { identity })
|
|
||||||
const consistentLog = await orbitdb.log('concurrent', { syncLocal: true, sortFn: Log.Sorting.SortByEntryHash })
|
|
||||||
const inconsistentLog = await orbitdb.log('concurrent2')
|
|
||||||
|
|
||||||
window.consistentLog = consistentLog
|
|
||||||
window.inconsistentLog = inconsistentLog
|
|
||||||
|
|
||||||
waitForOpenDB.innerHTML = consistentLog.address.toString() + ' + ' + inconsistentLog.address.toString()
|
|
||||||
await consistentLog.load()
|
|
||||||
await inconsistentLog.load()
|
|
||||||
|
|
||||||
// const updateData = () => {
|
|
||||||
// logData.innerHTML = ''
|
|
||||||
// const count = consistentlog.iterator({ limit: -1 }).collect().map(e => {
|
|
||||||
// logData.innerHTML += e.clock.time + ': ' + e.hash + '<br />'
|
|
||||||
// })
|
|
||||||
// }
|
|
||||||
|
|
||||||
addData.addEventListener('click', async event => {
|
|
||||||
const data = randStr()
|
|
||||||
await consistentLog.add(data)
|
|
||||||
await inconsistentLog.add(data)
|
|
||||||
})
|
|
||||||
})
|
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
|
|
||||||
const assert = require('assert')
|
const assert = require('assert')
|
||||||
const mapSeries = require('p-each-series')
|
const mapSeries = require('p-each-series')
|
||||||
const path = require('path')
|
|
||||||
const rmrf = require('rimraf')
|
const rmrf = require('rimraf')
|
||||||
const OrbitDB = require('../src/OrbitDB')
|
const OrbitDB = require('../src/OrbitDB')
|
||||||
// Include test utilities
|
// Include test utilities
|
||||||
@ -12,8 +11,8 @@ const {
|
|||||||
stopIpfs,
|
stopIpfs,
|
||||||
testAPIs,
|
testAPIs,
|
||||||
connectPeers,
|
connectPeers,
|
||||||
waitForPeers,
|
waitForPeers
|
||||||
} = require('./utils')
|
} = require('orbit-db-test-utils')
|
||||||
|
|
||||||
const dbPath1 = './orbitdb/tests/counters/peer1'
|
const dbPath1 = './orbitdb/tests/counters/peer1'
|
||||||
const dbPath2 = './orbitdb/tests/counters/peer2'
|
const dbPath2 = './orbitdb/tests/counters/peer2'
|
||||||
@ -21,7 +20,7 @@ const ipfsPath1 = './orbitdb/tests/counters/peer1/ipfs'
|
|||||||
const ipfsPath2 = './orbitdb/tests/counters/peer2/ipfs'
|
const ipfsPath2 = './orbitdb/tests/counters/peer2/ipfs'
|
||||||
|
|
||||||
Object.keys(testAPIs).forEach(API => {
|
Object.keys(testAPIs).forEach(API => {
|
||||||
describe(`orbit-db - Counters (${API})`, function() {
|
describe(`orbit-db - Counters (${API})`, function () {
|
||||||
this.timeout(config.timeout)
|
this.timeout(config.timeout)
|
||||||
|
|
||||||
let orbitdb1, orbitdb2
|
let orbitdb1, orbitdb2
|
||||||
@ -80,6 +79,7 @@ Object.keys(testAPIs).forEach(API => {
|
|||||||
it('value is zero when it\'s a fresh database', async () => {
|
it('value is zero when it\'s a fresh database', async () => {
|
||||||
const db = await orbitdb1.counter('counter database')
|
const db = await orbitdb1.counter('counter database')
|
||||||
assert.equal(db.value, 0)
|
assert.equal(db.value, 0)
|
||||||
|
await db.close()
|
||||||
})
|
})
|
||||||
|
|
||||||
it('increases a counter value', async () => {
|
it('increases a counter value', async () => {
|
||||||
@ -127,9 +127,12 @@ Object.keys(testAPIs).forEach(API => {
|
|||||||
|
|
||||||
return new Promise(resolve => {
|
return new Promise(resolve => {
|
||||||
// Wait for a while to make sure db's have been synced
|
// Wait for a while to make sure db's have been synced
|
||||||
setTimeout(() => {
|
setTimeout(async () => {
|
||||||
assert.equal(counter1.value, 30)
|
assert.equal(counter1.value, 30)
|
||||||
assert.equal(counter2.value, 30)
|
assert.equal(counter2.value, 30)
|
||||||
|
|
||||||
|
await counter1.close()
|
||||||
|
await counter2.close()
|
||||||
resolve()
|
resolve()
|
||||||
}, 1000)
|
}, 1000)
|
||||||
})
|
})
|
||||||
|
@ -19,7 +19,7 @@ const {
|
|||||||
startIpfs,
|
startIpfs,
|
||||||
stopIpfs,
|
stopIpfs,
|
||||||
testAPIs,
|
testAPIs,
|
||||||
} = require('./utils')
|
} = require('orbit-db-test-utils')
|
||||||
|
|
||||||
const dbPath = path.join('./orbitdb', 'tests', 'create-open')
|
const dbPath = path.join('./orbitdb', 'tests', 'create-open')
|
||||||
const ipfsPath = path.join('./orbitdb', 'tests', 'create-open', 'ipfs')
|
const ipfsPath = path.join('./orbitdb', 'tests', 'create-open', 'ipfs')
|
||||||
@ -40,7 +40,6 @@ Object.keys(testAPIs).forEach(API => {
|
|||||||
return !(src.includes('LOG') || src.includes('LOCK'))
|
return !(src.includes('LOG') || src.includes('LOCK'))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
before(async () => {
|
before(async () => {
|
||||||
config.daemon1.repo = ipfsPath
|
config.daemon1.repo = ipfsPath
|
||||||
rmrf.sync(config.daemon1.repo)
|
rmrf.sync(config.daemon1.repo)
|
||||||
@ -142,7 +141,7 @@ Object.keys(testAPIs).forEach(API => {
|
|||||||
it('saves database manifest file locally', async () => {
|
it('saves database manifest file locally', async () => {
|
||||||
const manifestHash = db.id.split('/')[2]
|
const manifestHash = db.id.split('/')[2]
|
||||||
const manifest = await io.read(ipfs, manifestHash)
|
const manifest = await io.read(ipfs, manifestHash)
|
||||||
assert.notEqual(manifest)
|
assert.notEqual(manifest, false)
|
||||||
assert.equal(manifest.name, 'second')
|
assert.equal(manifest.name, 'second')
|
||||||
assert.equal(manifest.type, 'feed')
|
assert.equal(manifest.type, 'feed')
|
||||||
assert.notEqual(manifest.accessController, null)
|
assert.notEqual(manifest.accessController, null)
|
||||||
|
@ -11,7 +11,7 @@ const {
|
|||||||
startIpfs,
|
startIpfs,
|
||||||
stopIpfs,
|
stopIpfs,
|
||||||
testAPIs,
|
testAPIs,
|
||||||
} = require('./utils')
|
} = require('orbit-db-test-utils')
|
||||||
|
|
||||||
const dbPath = './orbitdb/tests/create-open'
|
const dbPath = './orbitdb/tests/create-open'
|
||||||
const ipfsPath = './orbitdb/tests/create-open/ipfs'
|
const ipfsPath = './orbitdb/tests/create-open/ipfs'
|
||||||
|
@ -14,7 +14,10 @@ const {
|
|||||||
startIpfs,
|
startIpfs,
|
||||||
stopIpfs,
|
stopIpfs,
|
||||||
testAPIs,
|
testAPIs,
|
||||||
databases,
|
} = require('orbit-db-test-utils')
|
||||||
|
|
||||||
|
const {
|
||||||
|
databases
|
||||||
} = require('./utils')
|
} = require('./utils')
|
||||||
|
|
||||||
const dbPath = './orbitdb/tests/customKeystore'
|
const dbPath = './orbitdb/tests/customKeystore'
|
||||||
@ -24,10 +27,10 @@ Object.keys(testAPIs).forEach(API => {
|
|||||||
describe(`orbit-db - Use a Custom Cache (${API})`, function() {
|
describe(`orbit-db - Use a Custom Cache (${API})`, function() {
|
||||||
this.timeout(20000)
|
this.timeout(20000)
|
||||||
|
|
||||||
let ipfsd, ipfs, orbitdb1
|
let ipfsd, ipfs, orbitdb1, store
|
||||||
|
|
||||||
before(async () => {
|
before(async () => {
|
||||||
const store = await storage.createStore("local")
|
store = await storage.createStore("local")
|
||||||
const cache = new CustomCache(store)
|
const cache = new CustomCache(store)
|
||||||
|
|
||||||
config.daemon1.repo = ipfsPath
|
config.daemon1.repo = ipfsPath
|
||||||
@ -42,24 +45,20 @@ Object.keys(testAPIs).forEach(API => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
after(async () => {
|
after(async () => {
|
||||||
if(orbitdb1)
|
await orbitdb1.stop()
|
||||||
await orbitdb1.stop()
|
await stopIpfs(ipfsd)
|
||||||
|
|
||||||
if (ipfsd)
|
|
||||||
await stopIpfs(ipfsd)
|
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('allows orbit to use a custom cache with different store types', function() {
|
describe('allows orbit to use a custom cache with different store types', function() {
|
||||||
databases.forEach(async (database) => {
|
for (let database of databases) {
|
||||||
it(database.type + ' allows custom keystore', async () => {
|
it(database.type + ' allows custom cache', async () => {
|
||||||
const db1 = await database.create(orbitdb1, 'custom-keystore')
|
const db1 = await database.create(orbitdb1, 'custom-keystore')
|
||||||
await database.tryInsert(db1)
|
await database.tryInsert(db1)
|
||||||
|
|
||||||
assert.deepEqual(database.getTestValue(db1), database.expectedValue)
|
assert.deepEqual(database.getTestValue(db1), database.expectedValue)
|
||||||
|
|
||||||
await db1.close()
|
await db1.close()
|
||||||
})
|
})
|
||||||
})
|
}
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -11,6 +11,9 @@ const {
|
|||||||
startIpfs,
|
startIpfs,
|
||||||
stopIpfs,
|
stopIpfs,
|
||||||
testAPIs,
|
testAPIs,
|
||||||
|
} = require('orbit-db-test-utils')
|
||||||
|
|
||||||
|
const {
|
||||||
CustomTestKeystore,
|
CustomTestKeystore,
|
||||||
databases,
|
databases,
|
||||||
} = require('./utils')
|
} = require('./utils')
|
||||||
@ -40,11 +43,8 @@ Object.keys(testAPIs).forEach(API => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
after(async () => {
|
after(async () => {
|
||||||
if(orbitdb1)
|
await orbitdb1.stop()
|
||||||
await orbitdb1.stop()
|
await stopIpfs(ipfsd)
|
||||||
|
|
||||||
if (ipfsd)
|
|
||||||
await stopIpfs(ipfsd)
|
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('allows orbit to use a custom keystore with different store types', function() {
|
describe('allows orbit to use a custom keystore with different store types', function() {
|
||||||
|
@ -11,7 +11,7 @@ const {
|
|||||||
startIpfs,
|
startIpfs,
|
||||||
stopIpfs,
|
stopIpfs,
|
||||||
testAPIs,
|
testAPIs,
|
||||||
} = require('./utils')
|
} = require('orbit-db-test-utils')
|
||||||
|
|
||||||
const dbPath = './orbitdb/tests/docstore'
|
const dbPath = './orbitdb/tests/docstore'
|
||||||
const ipfsPath = './orbitdb/tests/docstore/ipfs'
|
const ipfsPath = './orbitdb/tests/docstore/ipfs'
|
||||||
@ -52,7 +52,7 @@ Object.keys(testAPIs).forEach(API => {
|
|||||||
maxHistory: 0,
|
maxHistory: 0,
|
||||||
path: dbPath,
|
path: dbPath,
|
||||||
}
|
}
|
||||||
db = await orbitdb1.docstore(config.dbname, options)
|
db = await orbitdb1.docstore('orbit-db-tests', options)
|
||||||
})
|
})
|
||||||
|
|
||||||
afterEach(async () => {
|
afterEach(async () => {
|
||||||
@ -177,7 +177,7 @@ Object.keys(testAPIs).forEach(API => {
|
|||||||
replicate: false,
|
replicate: false,
|
||||||
maxHistory: 0
|
maxHistory: 0
|
||||||
}
|
}
|
||||||
db = await orbitdb1.docstore(config.dbname, options)
|
db = await orbitdb1.docstore('orbit-db-tests', options)
|
||||||
})
|
})
|
||||||
|
|
||||||
afterEach(async () => {
|
afterEach(async () => {
|
||||||
|
@ -12,7 +12,7 @@ const {
|
|||||||
startIpfs,
|
startIpfs,
|
||||||
stopIpfs,
|
stopIpfs,
|
||||||
testAPIs,
|
testAPIs,
|
||||||
} = require('./utils')
|
} = require('orbit-db-test-utils')
|
||||||
|
|
||||||
const dbPath = './orbitdb/tests/drop'
|
const dbPath = './orbitdb/tests/drop'
|
||||||
const ipfsPath = './orbitdb/tests/drop/ipfs'
|
const ipfsPath = './orbitdb/tests/drop/ipfs'
|
||||||
|
@ -12,7 +12,7 @@ const {
|
|||||||
startIpfs,
|
startIpfs,
|
||||||
stopIpfs,
|
stopIpfs,
|
||||||
testAPIs,
|
testAPIs,
|
||||||
} = require('./utils')
|
} = require('orbit-db-test-utils')
|
||||||
|
|
||||||
const last = arr => arr[arr.length - 1]
|
const last = arr => arr[arr.length - 1]
|
||||||
|
|
||||||
|
@ -12,7 +12,7 @@ const {
|
|||||||
startIpfs,
|
startIpfs,
|
||||||
stopIpfs,
|
stopIpfs,
|
||||||
testAPIs,
|
testAPIs,
|
||||||
} = require('./utils')
|
} = require('orbit-db-test-utils')
|
||||||
|
|
||||||
const last = arr => arr[arr.length - 1]
|
const last = arr => arr[arr.length - 1]
|
||||||
|
|
||||||
|
@ -12,7 +12,7 @@ const {
|
|||||||
startIpfs,
|
startIpfs,
|
||||||
stopIpfs,
|
stopIpfs,
|
||||||
testAPIs,
|
testAPIs,
|
||||||
} = require('./utils')
|
} = require('orbit-db-test-utils')
|
||||||
|
|
||||||
const last = arr => arr[arr.length - 1]
|
const last = arr => arr[arr.length - 1]
|
||||||
|
|
||||||
|
@ -11,7 +11,7 @@ const {
|
|||||||
startIpfs,
|
startIpfs,
|
||||||
stopIpfs,
|
stopIpfs,
|
||||||
testAPIs,
|
testAPIs,
|
||||||
} = require('./utils')
|
} = require('orbit-db-test-utils')
|
||||||
|
|
||||||
const dbPath = './orbitdb/tests/kvstore'
|
const dbPath = './orbitdb/tests/kvstore'
|
||||||
const ipfsPath = './orbitdb/tests/kvstore/ipfs'
|
const ipfsPath = './orbitdb/tests/kvstore/ipfs'
|
||||||
@ -31,16 +31,15 @@ Object.keys(testAPIs).forEach(API => {
|
|||||||
orbitdb1 = await OrbitDB.createInstance(ipfs, { directory: path.join(dbPath, '1') })
|
orbitdb1 = await OrbitDB.createInstance(ipfs, { directory: path.join(dbPath, '1') })
|
||||||
})
|
})
|
||||||
|
|
||||||
after(async () => {
|
after(() => {
|
||||||
if(orbitdb1)
|
setTimeout(async () => {
|
||||||
await orbitdb1.stop()
|
await orbitdb1.stop()
|
||||||
|
|
||||||
if (ipfsd)
|
|
||||||
await stopIpfs(ipfsd)
|
await stopIpfs(ipfsd)
|
||||||
|
}, 0)
|
||||||
})
|
})
|
||||||
|
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
db = await orbitdb1.kvstore(config.dbname, { path: dbPath })
|
db = await orbitdb1.kvstore('orbit-db-tests', { path: dbPath })
|
||||||
})
|
})
|
||||||
|
|
||||||
afterEach(async () => {
|
afterEach(async () => {
|
||||||
|
@ -13,7 +13,7 @@ const {
|
|||||||
connectPeers,
|
connectPeers,
|
||||||
waitForPeers,
|
waitForPeers,
|
||||||
testAPIs,
|
testAPIs,
|
||||||
} = require('./utils')
|
} = require('orbit-db-test-utils')
|
||||||
|
|
||||||
const dbPath1 = './orbitdb/tests/multiple-databases/1'
|
const dbPath1 = './orbitdb/tests/multiple-databases/1'
|
||||||
const dbPath2 = './orbitdb/tests/multiple-databases/2'
|
const dbPath2 = './orbitdb/tests/multiple-databases/2'
|
||||||
|
@ -18,7 +18,7 @@ const {
|
|||||||
startIpfs,
|
startIpfs,
|
||||||
stopIpfs,
|
stopIpfs,
|
||||||
testAPIs,
|
testAPIs,
|
||||||
} = require('./utils')
|
} = require('orbit-db-test-utils')
|
||||||
|
|
||||||
const dbPath1 = './orbitdb/tests/offline/db1'
|
const dbPath1 = './orbitdb/tests/offline/db1'
|
||||||
const dbPath2 = './orbitdb/tests/offline/db2'
|
const dbPath2 = './orbitdb/tests/offline/db2'
|
||||||
|
@ -13,7 +13,7 @@ const {
|
|||||||
startIpfs,
|
startIpfs,
|
||||||
stopIpfs,
|
stopIpfs,
|
||||||
testAPIs
|
testAPIs
|
||||||
} = require('./utils')
|
} = require('orbit-db-test-utils')
|
||||||
|
|
||||||
Object.keys(testAPIs).forEach(API => {
|
Object.keys(testAPIs).forEach(API => {
|
||||||
describe(`orbit-db - OrbitDB Address (${API})`, function() {
|
describe(`orbit-db - OrbitDB Address (${API})`, function() {
|
||||||
|
@ -16,7 +16,7 @@ const {
|
|||||||
startIpfs,
|
startIpfs,
|
||||||
stopIpfs,
|
stopIpfs,
|
||||||
testAPIs
|
testAPIs
|
||||||
} = require('./utils')
|
} = require('orbit-db-test-utils')
|
||||||
|
|
||||||
const dbPath = './orbitdb/tests/persistency'
|
const dbPath = './orbitdb/tests/persistency'
|
||||||
const ipfsPath = './orbitdb/tests/persistency/ipfs'
|
const ipfsPath = './orbitdb/tests/persistency/ipfs'
|
||||||
|
20
test/re-exports.test.js
Normal file
20
test/re-exports.test.js
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
'use strict'
|
||||||
|
|
||||||
|
const assert = require('assert')
|
||||||
|
const { AccessControllers, Identities, Keystore } = require('../src/OrbitDB')
|
||||||
|
|
||||||
|
describe('Re-exports', function () {
|
||||||
|
it('Successfully re-exports AccessControllers', () => {
|
||||||
|
assert.strictEqual(typeof AccessControllers, 'function')
|
||||||
|
assert.strictEqual(typeof AccessControllers.addAccessController, 'function')
|
||||||
|
})
|
||||||
|
|
||||||
|
it('Successfully re-exports Identities', () => {
|
||||||
|
assert.strictEqual(typeof Identities, 'function')
|
||||||
|
assert.strictEqual(typeof Identities.createIdentity, 'function')
|
||||||
|
})
|
||||||
|
|
||||||
|
it('Successfully re-exports Keystore', () => {
|
||||||
|
assert.strictEqual(typeof Keystore, 'function')
|
||||||
|
})
|
||||||
|
})
|
@ -13,7 +13,7 @@ const {
|
|||||||
testAPIs,
|
testAPIs,
|
||||||
connectPeers,
|
connectPeers,
|
||||||
waitForPeers,
|
waitForPeers,
|
||||||
} = require('./utils')
|
} = require('orbit-db-test-utils')
|
||||||
|
|
||||||
const dbPath1 = './orbitdb/tests/replicate-and-load/1'
|
const dbPath1 = './orbitdb/tests/replicate-and-load/1'
|
||||||
const dbPath2 = './orbitdb/tests/replicate-and-load/2'
|
const dbPath2 = './orbitdb/tests/replicate-and-load/2'
|
||||||
|
@ -13,7 +13,7 @@ const {
|
|||||||
testAPIs,
|
testAPIs,
|
||||||
connectPeers,
|
connectPeers,
|
||||||
waitForPeers,
|
waitForPeers,
|
||||||
} = require('./utils')
|
} = require('orbit-db-test-utils')
|
||||||
|
|
||||||
const dbPath1 = './orbitdb/tests/replicate-automatically/1'
|
const dbPath1 = './orbitdb/tests/replicate-automatically/1'
|
||||||
const dbPath2 = './orbitdb/tests/replicate-automatically/2'
|
const dbPath2 = './orbitdb/tests/replicate-automatically/2'
|
||||||
|
@ -14,7 +14,7 @@ const {
|
|||||||
connectPeers,
|
connectPeers,
|
||||||
waitForPeers,
|
waitForPeers,
|
||||||
MemStore,
|
MemStore,
|
||||||
} = require('./utils')
|
} = require('orbit-db-test-utils')
|
||||||
|
|
||||||
const dbPath1 = './orbitdb/tests/replication/1'
|
const dbPath1 = './orbitdb/tests/replication/1'
|
||||||
const dbPath2 = './orbitdb/tests/replication/2'
|
const dbPath2 = './orbitdb/tests/replication/2'
|
||||||
|
@ -16,7 +16,7 @@ const {
|
|||||||
startIpfs,
|
startIpfs,
|
||||||
stopIpfs,
|
stopIpfs,
|
||||||
testAPIs,
|
testAPIs,
|
||||||
} = require('./utils')
|
} = require('orbit-db-test-utils')
|
||||||
|
|
||||||
const dbPath1 = './orbitdb/tests/create-open/1'
|
const dbPath1 = './orbitdb/tests/create-open/1'
|
||||||
const dbPath2 = './orbitdb/tests/create-open/2'
|
const dbPath2 = './orbitdb/tests/create-open/2'
|
||||||
|
@ -16,7 +16,7 @@ const {
|
|||||||
startIpfs,
|
startIpfs,
|
||||||
stopIpfs,
|
stopIpfs,
|
||||||
testAPIs,
|
testAPIs,
|
||||||
} = require('./utils')
|
} = require('orbit-db-test-utils')
|
||||||
|
|
||||||
const keysPath = './orbitdb/identity/identitykeys'
|
const keysPath = './orbitdb/identity/identitykeys'
|
||||||
const dbPath = './orbitdb/tests/change-identity'
|
const dbPath = './orbitdb/tests/change-identity'
|
||||||
|
@ -26,7 +26,7 @@ const {
|
|||||||
startIpfs,
|
startIpfs,
|
||||||
stopIpfs,
|
stopIpfs,
|
||||||
testAPIs,
|
testAPIs,
|
||||||
} = require('./utils')
|
} = require('orbit-db-test-utils')
|
||||||
|
|
||||||
const dbPath = path.join('./orbitdb', 'tests', 'v0')
|
const dbPath = path.join('./orbitdb', 'tests', 'v0')
|
||||||
const dbFixturesDir = path.join('./test', 'fixtures', 'v0', 'QmWDUfC4zcWJGgc9UHn1X3qQ5KZqBv4KCiCtjnpMmBT8JC', 'v0-db')
|
const dbFixturesDir = path.join('./test', 'fixtures', 'v0', 'QmWDUfC4zcWJGgc9UHn1X3qQ5KZqBv4KCiCtjnpMmBT8JC', 'v0-db')
|
||||||
@ -61,10 +61,11 @@ Object.keys(testAPIs).forEach(API => {
|
|||||||
await fs.copy(path.join(ipfsFixturesDir, 'blocks'), path.join(ipfsd.path, 'blocks'))
|
await fs.copy(path.join(ipfsFixturesDir, 'blocks'), path.join(ipfsd.path, 'blocks'))
|
||||||
await fs.copy(path.join(ipfsFixturesDir, 'datastore'), path.join(ipfsd.path, 'datastore'), { filter: filterFunc })
|
await fs.copy(path.join(ipfsFixturesDir, 'datastore'), path.join(ipfsd.path, 'datastore'), { filter: filterFunc })
|
||||||
|
|
||||||
const store = await storage.createStore(path.join(dbPath, ipfs._peerInfo.id._idB58String, 'keys'))
|
const peerId = (await ipfs.id()).id
|
||||||
|
const store = await storage.createStore(path.join(dbPath, peerId, 'keys'))
|
||||||
keystore = new Keystore(store)
|
keystore = new Keystore(store)
|
||||||
|
|
||||||
let identity = await Identities.createIdentity({ id: ipfs._peerInfo.id._idB58String, migrate: migrate(keyFixtures), keystore })
|
let identity = await Identities.createIdentity({ id: peerId, migrate: migrate(keyFixtures), keystore })
|
||||||
orbitdb = await OrbitDB.createInstance(ipfs, { identity, keystore })
|
orbitdb = await OrbitDB.createInstance(ipfs, { identity, keystore })
|
||||||
|
|
||||||
})
|
})
|
||||||
|
@ -10,7 +10,10 @@ const {
|
|||||||
config,
|
config,
|
||||||
startIpfs,
|
startIpfs,
|
||||||
stopIpfs,
|
stopIpfs,
|
||||||
testAPIs,
|
testAPIs
|
||||||
|
} = require('orbit-db-test-utils')
|
||||||
|
|
||||||
|
const {
|
||||||
databases
|
databases
|
||||||
} = require('./utils')
|
} = require('./utils')
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user