mirror of
https://github.com/orbitdb/orbitdb.git
synced 2025-10-07 22:57:07 +00:00
Cleanups
This commit is contained in:
@@ -12,37 +12,32 @@ const port = 3333;
|
||||
const username = process.argv[3] ? process.argv[3] : 'LambOfGod';
|
||||
const password = '';
|
||||
|
||||
let running = false;
|
||||
let run = (async(() => {
|
||||
if(!running) {
|
||||
try {
|
||||
running = true;
|
||||
const orbit = OrbitClient.connect(host, port, username, password);
|
||||
const channel = process.argv[2] ? process.argv[2] : 'testing123';
|
||||
const db = orbit.channel(channel);
|
||||
try {
|
||||
const orbit = OrbitClient.connect(host, port, username, password);
|
||||
const channel = process.argv[2] ? process.argv[2] : 'testing123';
|
||||
const db = orbit.channel(channel);
|
||||
|
||||
let count = 1;
|
||||
let count = 1;
|
||||
|
||||
setInterval(async(() => {
|
||||
const key = process.argv[4] ? process.argv[4] : 'greeting';
|
||||
let timer = new Timer(true);
|
||||
let v = db.get(key);
|
||||
setInterval(async(() => {
|
||||
const key = process.argv[4] ? process.argv[4] : 'greeting';
|
||||
let timer = new Timer(true);
|
||||
let v = db.get(key);
|
||||
|
||||
console.log("---------------------------------------------------")
|
||||
console.log("Key | Value")
|
||||
console.log("---------------------------------------------------")
|
||||
console.log(`${key} | ${v}`);
|
||||
console.log("---------------------------------------------------")
|
||||
console.log(`Query #${count} took ${timer.stop(true)} ms\n`);
|
||||
console.log("---------------------------------------------------")
|
||||
console.log("Key | Value")
|
||||
console.log("---------------------------------------------------")
|
||||
console.log(`${key} | ${v}`);
|
||||
console.log("---------------------------------------------------")
|
||||
console.log(`Query #${count} took ${timer.stop(true)} ms\n`);
|
||||
|
||||
count ++;
|
||||
running = false;
|
||||
}), 1000);
|
||||
} catch(e) {
|
||||
console.error("error:", e);
|
||||
console.error(e.stack);
|
||||
process.exit(1);
|
||||
}
|
||||
count ++;
|
||||
}), 1000);
|
||||
} catch(e) {
|
||||
console.error("error:", e);
|
||||
console.error(e.stack);
|
||||
process.exit(1);
|
||||
}
|
||||
}))();
|
||||
|
||||
|
||||
@@ -33,14 +33,12 @@ let run = (async(() => {
|
||||
console.log(`Query #${count} took ${timer.stop(true)} ms\n`);
|
||||
|
||||
let timer2 = new Timer(true);
|
||||
// const c = channel.iterator({ limit: -1 }).collect().length;
|
||||
let items = channel.iterator({ limit: 10 }).collect();
|
||||
console.log("---------------------------------------------------")
|
||||
console.log("Key | Value")
|
||||
console.log("---------------------------------------------------")
|
||||
console.log(items.map((e) => `${e.payload.key} | ${e.payload.value}`).join("\n"));
|
||||
console.log("---------------------------------------------------")
|
||||
// console.log(`Found ${items.length} items from ${c}\n`);
|
||||
console.log(`Query 2 #${count} took ${timer2.stop(true)} ms\n`);
|
||||
|
||||
running = false;
|
||||
|
||||
@@ -15,8 +15,6 @@ const PubSub = require('./PubSub');
|
||||
const List = require('./list/OrbitList');
|
||||
const DataStore = require('./DataStore');
|
||||
|
||||
var Timer = require('../examples/Timer');
|
||||
|
||||
const pubkey = Keystore.getKeys().publicKey;
|
||||
const privkey = Keystore.getKeys().privateKey;
|
||||
|
||||
|
||||
@@ -10,7 +10,6 @@ class Pubsub {
|
||||
this._socket = io(`http://${host}:${port}`);
|
||||
this._socket.on('connect', (socket) => console.log(`Connected to http://${host}:${port}`));
|
||||
this._socket.on('disconnect', (socket) => console.log(`Disconnected from http://${host}:${port}`));
|
||||
this._socket.on('event', (e) => console.log('Event:', e));
|
||||
this._socket.on('error', (e) => console.log('error:', e));
|
||||
this._socket.on('message', this._handleMessage.bind(this));
|
||||
this._socket.on('latest', (hash, message) => {
|
||||
|
||||
@@ -35,7 +35,6 @@ class OrbitList extends List {
|
||||
|
||||
// WIP: fetch missing nodes
|
||||
let depth = 0;
|
||||
|
||||
const isReferenced = (all, item) => _.findLast(all, (f) => f === item) !== undefined;
|
||||
const fetchRecursive = (hash) => {
|
||||
hash = hash instanceof Node === true ? hash.hash : hash;
|
||||
|
||||
@@ -30,24 +30,6 @@ describe('Orbit Client', () => {
|
||||
done();
|
||||
}));
|
||||
|
||||
/*
|
||||
describe('Info', function() { // }
|
||||
// };
|
||||
// var res = db.setMode(mode)
|
||||
// var info = orbit.channel(channel, 'password').info();
|
||||
// assert.notEqual(info, null);
|
||||
// assert.equal(info.head, null);
|
||||
// assert.equal(JSON.stringify(info.modes), JSON.stringify(res));
|
||||
// orbit.channel(channel, 'password').delete();
|
||||
// } catch(e) {
|
||||
// orbit.channel(channel, 'password').delete();
|
||||
// assert.equal(e, null);
|
||||
// }
|
||||
// done();
|
||||
// }));
|
||||
});
|
||||
*/
|
||||
|
||||
describe('Add events', function() {
|
||||
it('adds an item to an empty channel', async((done) => {
|
||||
const head = db.add('hello');
|
||||
|
||||
Reference in New Issue
Block a user