mirror of
https://github.com/orbitdb/orbitdb.git
synced 2025-05-28 17:56:37 +00:00
Cleanup
This commit is contained in:
parent
06ee3ebf31
commit
c7dd79bda8
@ -28,6 +28,7 @@ class OperationsLog {
|
||||
return this._log.add(entry)
|
||||
.then((op) => node = op)
|
||||
.then(() => {
|
||||
// Add the hash of the log entry to the payload
|
||||
Object.assign(node.payload, { hash: node.hash });
|
||||
if(node.payload.key === null)
|
||||
Object.assign(node.payload, { key: node.hash });
|
||||
|
@ -18,8 +18,7 @@ class CounterIndex {
|
||||
updateIndex(oplog, updated) {
|
||||
const counter = this._index[oplog.dbname];
|
||||
if(counter) {
|
||||
updated
|
||||
.filter((f) => f && f.op === 'COUNTER')
|
||||
updated.filter((f) => f && f.op === 'COUNTER')
|
||||
.map((f) => Counter.from(f.value))
|
||||
.forEach((f) => counter.merge(f))
|
||||
|
||||
|
@ -540,16 +540,6 @@ describe('Orbit Client', function() {
|
||||
done();
|
||||
});
|
||||
|
||||
it('put', async((done) => {
|
||||
const db2 = await(client2.kvstore(channel, false));
|
||||
await(db.put('key1', 'hello1'));
|
||||
await(db2.put('key1', 'hello2'));
|
||||
await(db.sync('QmNtELU2N3heY9cFgRuLWavgov7NTXibNyZCxcTCYjw1TM'))
|
||||
const value = db.get('key1');
|
||||
assert.equal(value, 'hello2');
|
||||
done();
|
||||
}));
|
||||
|
||||
it('put', async((done) => {
|
||||
await(db.put('key1', 'hello!'));
|
||||
const value = db.get('key1');
|
||||
@ -625,5 +615,15 @@ describe('Orbit Client', function() {
|
||||
assert.equal(_.isEqual(v1, val), true);
|
||||
done();
|
||||
}));
|
||||
|
||||
it('syncs databases', async((done) => {
|
||||
const db2 = await(client2.kvstore(channel, false));
|
||||
await(db.put('key1', 'hello1'));
|
||||
await(db2.put('key1', 'hello2'));
|
||||
await(db.sync('QmNtELU2N3heY9cFgRuLWavgov7NTXibNyZCxcTCYjw1TM'))
|
||||
const value = db.get('key1');
|
||||
assert.equal(value, 'hello2');
|
||||
done();
|
||||
}));
|
||||
});
|
||||
});
|
||||
|
@ -92,7 +92,6 @@ describe('CounterStore', function() {
|
||||
it('syncs counters', (done) => {
|
||||
const name = new Date().getTime();
|
||||
Promise.all([client1.counter(name), client2.counter(name)]).then((counters) => {
|
||||
// Promise.all([client1.counter(name)]).then((counters) => {
|
||||
const res1 = Promise.map([13, 10], (f) => counters[0].inc(f), { concurrency: 1 });
|
||||
const res2 = Promise.map([2, 5], (f) => counters[1].inc(f), { concurrency: 1 })
|
||||
Promise.all([res1, res2]).then((res) => {
|
||||
|
Loading…
x
Reference in New Issue
Block a user