orbit-db | Peer-to-Peer Databases for the Decentralized Web | Storage library
kandi X-RAY | orbit-db Summary
Support
Quality
Security
License
Reuse
- Main entry point .
- Handle error message
orbit-db Key Features
orbit-db Examples and Code Snippets
Trending Discussions on orbit-db
Trending Discussions on orbit-db
QUESTION
i'm only trying to launch the exemple of the app kit OrbitDB which is :
import OrbitDB from "orbit-db";
import IPFS from "ipfs";
async function main () {
// Create IPFS instance
const ipfsOptions = { repo : './ipfs', }
const ipfs = await IPFS.create(ipfsOptions)
// Create OrbitDB instance
const orbitdb = await OrbitDB.createInstance(ipfs)
// Create database instance
const db = await orbitdb.keyvalue('ipfs_db')
}
main()
you can find it here : https://github.com/dappkit/aviondb#using-nodejs
but the problem is when i launch it, i got these errors :
Swarm listening on /ip4/127.0.0.1/tcp/4002/p2p/12D3KooWM7D9NdMhtxyiWiKH4XVpuZW5oDu9MbWxFmEzLsG9UynM
Swarm listening on /ip4/192.168.1.53/tcp/4002/p2p/12D3KooWM7D9NdMhtxyiWiKH4XVpuZW5oDu9MbWxFmEzLsG9UynM
Swarm listening on /ip4/127.0.0.1/tcp/4003/ws/p2p/12D3KooWM7D9NdMhtxyiWiKH4XVpuZW5oDu9MbWxFmEzLsG9UynM
IPFSAccessController.save ERROR: Error: Deprecated, use .toString()
at CID.get toBaseEncodedString [as toBaseEncodedString] (/home/zar/Etna4/SmartContract/db_ipfs/node_modules/multiformats/cjs/src/cid.js:94:11)
at Object.writeCbor [as write] (/home/zar/Etna4/SmartContract/db_ipfs/node_modules/aviondb/node_modules/orbit-db-access-controllers/node_modules/orbit-db-io/index.js:62:14)
at async IPFSAccessController.save (/home/zar/Etna4/SmartContract/db_ipfs/node_modules/aviondb/node_modules/orbit-db-access-controllers/src/ipfs-access-controller.js:46:13)
at async Function.create (/home/zar/Etna4/SmartContract/db_ipfs/node_modules/aviondb/node_modules/orbit-db-access-controllers/src/access-controllers.js:68:20)
at async OrbitDB._determineAddress (/home/zar/Etna4/SmartContract/db_ipfs/node_modules/aviondb/node_modules/orbit-db/src/OrbitDB.js:331:37)
(node:8397) UnhandledPromiseRejectionWarning: Error: `undefined` is not supported by the IPLD Data Model and cannot be encoded
at undefinedEncoder (/home/zar/Etna4/SmartContract/db_ipfs/node_modules/@ipld/dag-cbor/cjs/index.js:47:9)
at objectToTokens (/home/zar/Etna4/SmartContract/db_ipfs/node_modules/cborg/cjs/lib/encode.js:175:20)
at Object (/home/zar/Etna4/SmartContract/db_ipfs/node_modules/cborg/cjs/lib/encode.js:149:9)
at objectToTokens (/home/zar/Etna4/SmartContract/db_ipfs/node_modules/cborg/cjs/lib/encode.js:184:10)
at Object (/home/zar/Etna4/SmartContract/db_ipfs/node_modules/cborg/cjs/lib/encode.js:149:9)
at objectToTokens (/home/zar/Etna4/SmartContract/db_ipfs/node_modules/cborg/cjs/lib/encode.js:184:10)
at encodeCustom (/home/zar/Etna4/SmartContract/db_ipfs/node_modules/cborg/cjs/lib/encode.js:214:18)
at Object.encode (/home/zar/Etna4/SmartContract/db_ipfs/node_modules/cborg/cjs/lib/encode.js:236:10)
at Object.encode (/home/zar/Etna4/SmartContract/db_ipfs/node_modules/@ipld/dag-cbor/cjs/index.js:85:41)
at put (/home/zar/Etna4/SmartContract/db_ipfs/node_modules/ipfs-core/src/components/dag/put.js:35:25)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:8397) 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:8397) [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.
i seriously don't know what to do, i tried to clear the cache, to delete node_modules
and package-lock.json
, and do a npm install
, but nothing changed, i got the same error, do you have any idea to fix this ?
ANSWER
Answered 2021-Sep-15 at 15:11This error clearly points to an incompatibility between IPFS and OrbitDB.
The latest version of js-ipfs
that OrbitDB v0.26.1 supports is 0.55.4
. You should change the ipfs
(or ipfs-core
) version in your package.json
to ^0.55.4
.
Note: The upcoming OrbitDB v0.27, will support the latest IPFS version.
QUESTION
Is it possible to implement a WebService over a WebRTC Data Channel ?
The idea is:
- The client makes one https request to the server for signaling and session establishment
- The client and the server start to communicate via a WebRTC DataChannel bidirectionally
Benefits?:
- Performance ?
- Requests goes over one connection and the standard allows for multiple datachannels over the same connection ( ports )
- Flexible networking topologies
- UDP
- End to end encryption
- The server can send events over the same connection
- Load balancing could be implemented from a pool of servers client side without a load balancer , or all kinds of different solutions
- Currently being debated the addition of DataChannels to Workers/Service Workers/ etc https://github.com/w3c/webrtc-extensions/issues/64
Drawbacks:
- Application specific code for implementing request fragmentation and control over buffer limits
- [EDIT 3] I don't know how much of a difference in terms of performance and cpu/memory usage will it be against HTTP/2 Stream
Ideas:
- Clients could be read replicas of the data for sync, or any other applications that are suitable for orbit-db https://github.com/orbitdb/orbit-db in the public IPFS network, the benefit of using orbit-db is that only allows to the owner to make writes, then the server could additionally sign with his key all the data so that the clients could verify and trust it's from the server, that could offload the main server for reads, just an idea.
[EDIT]
I've found this repo: https://github.com/jsmouret/grpc-over-webrtc amazing!
[EDIT2]
Changed Orbit-db idea and removed cluster IPFS after investigating a bit
[EDIT3]
After searching Fetch PROS for HTTP/2 i've found Fetch upload streaming with ReadableStreams, i don't know how much of a difference will it be to run GRPC (bidi) over a WebRTC DataChannel or a HTTP/2 Stream
Very cool video explaining the feature: https://www.youtube.com/watch?v=G9PpImUEeUA
ANSWER
Answered 2021-Apr-22 at 22:08Lots of different points here, will try to address them all.
The idea is 100% feasible. Check out Pion WebRTC's data-channels example. All it takes a single request/response to establish a connection.
PerformanceData channels are a much better fit if you are doing latency sensitive work.
With data channels you can measure backpressure. You can tell how much data has been delivered, and how much has has been queued. If the queue is getting full you know you are sending too much data. Other APIs in the browser don't give you this. There are some future APIs (WebTransport) but they aren't available yet.
Data channels allow unordered/unreliable delivery. With TCP everything you send will be delivered and in order, this issue is known as head-of-line blocking. That means if you lose a packet all subsequent packets must be delayed. An example would be if you sent 0 1 2 3
, if packet 1 hasn't arrived yet 2 and 3 can't be processed yet. Data channels can be configured to give you packets as soon as they arrive.
I can't give you specific numbers on the CPU/Memory costs of running DTLS+SCTP vs TLS+WebSocket server. It depends on hardware/network you have, what the workload is etc...
MultiplexingYou can serve multiple DataChannel streams over a single WebRTC Connection (PeerConnection). You can also serve multiple PeerConnections over a single port.
Network TransportWebRTC can be run over UDP or TCP
Load BalancingThis is harder (but not intractable) moving DTLS and SCTP sessions between servers isn't easy with existing libraries. With pion/dtls it has the support to export/resume a session. I don't know support in other libraries however.
TLS/Websocket is much easier to load balance.
End to end encryptionWebRTC has mandatory encryption. This is nice over HTTP 1.1 which might accidentally fall back to non-TLS if configured incorrectly.
If you want to route a message through the server (and not have the server see it) I don't think what protocol you use matters.
TopologiesWebRTC can be run in many different topologies. You can do P2P or Client/Server, and lots of things in between. Depending on what you are building you could build a hybrid mesh. You could create a graph of connections, and deploy servers as needed. This flexibility lets you do some interesting things.
Hopefully addressed all your points! Happy to discuss further in the comments/will keep editing the question.
QUESTION
In README on github i see this example
npm install orbit-db ipfs
const IPFS = require('ipfs')
const OrbitDB = require('orbit-db')
i am using es6 import
In example for browser on github
// Import IPFS module
import IPFS from 'ipfs'
// Import OrbitDB module from 'orbit-db', eg. directory to its package.json
import OrbitDB from '../../..'
But it is not work
I build es5 modules
npm run build:es5
it is build not es5 modules
ANSWER
Answered 2021-Mar-21 at 20:06To build this example run the following commands
npm install
npm run build:examples
after that you can open examples/browser/browser-webpack-example/index.html
in your browser.
Edit: We updated the documentation to run the examples
QUESTION
I am trying to use orbit-db along with the IPFS and I am going through the official documentation of OrbitDB. ATM, I am simply trying to create a db(specifically key-value store) and I have the following code uptil now
const IPFS = require('ipfs')
const OrbitDB = require('orbit-db')
createDb = async() => {
try {
const ipfsOptions = {
config: {
my-config-options
},
EXPERIMENTAL: {
pubsub: true
}
}
const ipfs = await IPFS.create(ipfsOptions)
const orbitdb = await OrbitDB.createInstance(ipfs)
const db = await orbitdb.create('test', 'keyvalue', {
overwrite: false,
replicate: true,
accessController: {
admin: ['*'],
write: ['*']
}
})
console.log(db)
await db.put('hello', { name: 'world' })
console.log(db.all)
} catch (error) {
console.trace(error)
}
}
But I keep getting the same error no matter what I try
Trace: Error: Could not append entry, key "..." is not allowed to write to the log
So any help would be much appreciated. Also do comment if any information is missing and I would add it as per the requirements
ANSWER
Answered 2020-Jun-24 at 08:17I think there's a small issue with your accessController
. The presence of the admin
property indicates that you want to use the orbitdb
type like this:
accessController: {
type: 'orbitdb',
admin: ['*'],
write: ['*']
}
Otherwise if you wish to use the default ipfs
type, remove the admin property like this:
accessController: {
type: 'ipfs',
write: ['*']
}
QUESTION
I'm trying to use Orbit-DB, So I follow the guide. But at the Create a database step, I get an error:
const ipfs = new IPFS()
^
TypeError: IPFS is not a constructor
Here is my full code:
const IPFS = require('ipfs')
const OrbitDB = require('orbit-db')
// Create IPFS instance
const ipfs = new IPFS()
ipfs.on('ready', async () => {
const orbitdb = await OrbitDB.createInstance(ipfs)
const db = await orbitdb.docs('opews-db-test1')
const address = db.address
})
I checked that there was no error in the require()
with a console.log()
, but it seems not. So I don't know how to fix that...
ANSWER
Answered 2020-May-13 at 09:18IPFS has changed the way you construct an IPFS node, can you try this code:
const IPFS = require('ipfs')
const OrbitDB = require('orbit-db')
async function main() {
const ipfs = await IPFS.create();
const orbitdb = await OrbitDB.createInstance(ipfs);
const db = await orbitdb.docs('opews-db-test1');
const address = db.address;
}
main();
QUESTION
I'm trying to build a Dapp with Nodejs and IPFS/OrbitDB every time, I try to start my App I get the error:
this.node = new IPFS({ ^
TypeError: IPFS is not a constructor
This is my basic code without a specific Swarm:
const Ipfs = require('ipfs');
const OrbitDB = require('orbit-db');
class chatroom {
constructor(IPFS, OrbitDB) {
this.OrbitDB = OrbitDB;
this.node = new IPFS({
preload: {enable: false},
repo: "./ipfs",
EXPERIMENTAL: {pubsub: true},
config: {
Bootstrap: [],
Addresses: {Swarm: []}
}
});
this.node.on("error", (e) => {throw (e)});
this.node.on("ready", this._init.bind(this));
}
async _init(){
this.orbitdb = await this.OrbitDB.createInstance(this.node);
this.onready();
}
}
module.exports = exports = new chatroom(Ipfs, OrbitDB);
I'm running on the following version of IPFS: ipfs@0.42.0
I tried it also on an empty Nodejs App and there I had the same error also when I added a specific Swarm to connect to.
I would really appreciate your help, thx for your time in advance.
Kind regards
beni
ANSWER
Answered 2020-Apr-21 at 15:09I did it now like that:
const IPFS = require('ipfs');
async function createNode() {
let node = await IPFS.create(
{
repo: (() => `repo-${Math.random()}`)(),
"Addresses": {
"Swarm": [
"/ip4/0.0.0.0/tcp/4001"
],
"API": "/ip4/127.0.0.1/tcp/5001",
"Gateway": "/ip4/127.0.0.1/tcp/8080"
}
}
);
try {
await node.start();
console.log('Node started!');
} catch (error) {
console.error('Node failed to start!', error);
}
}
(thx @Eugene)
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install orbit-db
Support
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesExplore Kits - Develop, implement, customize Projects, Custom Functions and Applications with kandi kits
Save this library and start creating your kit
Share this Page