The following test works in the browser node, with data that node.js controller created.:
var dbaddr = "/orbitdb/Qm............/testDB"
var db = await orbitdb.open(dbaddr);
await db.load();
setTimeout(function() {
var entries = db.iterator({ limit: -1 }).collect();
assert.equal(entries.length, 5, "tlTestDB read from server");
done();
}, 2000)
However, trying to move data in the opposite direction doesn't work.
In the browser, after ensuring peers are connected.
var url = `https://myapi.com/test-db/?peer=${peerID}&addr=${db.id}`;
var res = await fetch(url);
var text = await res.text()
assert.equal(text, "Cloud Test"); // text = "" or undefined
And on the server, that endpoint does the following:
// Is the peer actually connecting??
await td.ipfs.swarm.connect(req.query.peer)
var peers = await td.ipfs.swarm.peers();
console.log(peers.map(p => p.peer._idB58String).filter(a => a === req.query.peer.split("/")[3]));
// If the peer is connected, can it connect to the DB?
var testDB = await td.orbitdb.open(req.query.addr);
console.log(testDB.type);
// And can it fetch the title?
await testDB.load();
res.end(testDB.get("title")); // returns undefined
Pubsub is turned on on all nodes, are are hop / circuit / relay, etc. relay: { enabled: true, hop: { enabled: true, active: true } }
What's curious is that console.log(testDB.type) returns the right type of db, keyvalue in this case, without me telling the server anything about the database.
The text was updated successfully, but these errors were encountered:
aphelionz commentedNov 10, 2018
Advanced implementation question - I have:
[browser node (js-ipfs)] <---> [server node (go-ipfs)] <----> [node.js orbitdb controller (js-ipfs-api)]The following test works in the browser node, with data that node.js controller created.:
However, trying to move data in the opposite direction doesn't work.
In the browser, after ensuring peers are connected.
And on the server, that endpoint does the following:
Pubsub is turned on on all nodes, are are hop / circuit / relay, etc.
relay: { enabled: true, hop: { enabled: true, active: true } }What's curious is that
console.log(testDB.type)returns the right type of db,keyvaluein this case, without me telling the server anything about the database.The text was updated successfully, but these errors were encountered: