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