db: migrate to key objects.

This commit is contained in:
Christopher Jeffrey 2017-11-29 15:35:00 -08:00
parent a8e2001015
commit 167304666b
No known key found for this signature in database
GPG Key ID: 8962AB9DE6666BBD
6 changed files with 180 additions and 535 deletions

View File

@ -496,7 +496,7 @@ class ChainDB {
*/
async getState() {
const data = await this.db.get(layout.R);
const data = await this.db.get(layout.R());
if (!data)
return null;
@ -525,7 +525,7 @@ class ChainDB {
*/
async getFlags() {
const data = await this.db.get(layout.O);
const data = await this.db.get(layout.O());
if (!data)
return null;
@ -660,7 +660,7 @@ class ChainDB {
bw.writeI32(deployment.window);
}
batch.put(layout.V, bw.render());
batch.put(layout.V(), bw.render());
}
/**
@ -670,7 +670,7 @@ class ChainDB {
*/
async checkDeployments() {
const raw = await this.db.get(layout.V);
const raw = await this.db.get(layout.V());
assert(raw, 'No deployment table found.');
@ -792,7 +792,7 @@ class ChainDB {
const flags = ChainFlags.fromOptions(options);
assert(flags.prune);
batch.put(layout.O, flags.toRaw());
batch.put(layout.O(), flags.toRaw());
await batch.write();
} catch (e) {
@ -1414,7 +1414,7 @@ class ChainDB {
await this.saveBlock(entry, block, view);
// Commit new chain state.
this.put(layout.R, this.pending.commit(hash));
this.put(layout.R(), this.pending.commit(hash));
}
/**
@ -1467,7 +1467,7 @@ class ChainDB {
await this.connectBlock(entry, block, view);
// Update chain state.
this.put(layout.R, this.pending.commit(hash));
this.put(layout.R(), this.pending.commit(hash));
}
/**
@ -1516,7 +1516,7 @@ class ChainDB {
const view = await this.disconnectBlock(entry, block);
// Revert chain state to previous tip.
this.put(layout.R, this.pending.commit(entry.prevBlock));
this.put(layout.R(), this.pending.commit(entry.prevBlock));
return view;
}
@ -1575,7 +1575,7 @@ class ChainDB {
// Stop once we hit our target tip.
if (tip.hash === entry.hash) {
this.put(layout.R, this.pending.commit(tip.hash));
this.put(layout.R(), this.pending.commit(tip.hash));
await this.commit();
break;
}
@ -1602,7 +1602,7 @@ class ChainDB {
}
// Revert chain state to previous tip.
this.put(layout.R, this.pending.commit(tip.prevBlock));
this.put(layout.R(), this.pending.commit(tip.prevBlock));
await this.commit();
@ -1891,7 +1891,7 @@ class ChainDB {
saveFlags() {
const flags = ChainFlags.fromOptions(this.options);
const batch = this.db.batch();
batch.put(layout.O, flags.toRaw());
batch.put(layout.O(), flags.toRaw());
return batch.write();
}

View File

@ -7,6 +7,7 @@
'use strict';
const assert = require('assert');
const Key = require('bdb/lib/key');
/*
* Database Layout:
@ -29,168 +30,69 @@ const assert = require('assert');
* W+C[witaddr-hash][hash][index] -> dummy (coin by address)
*/
const R = new Key('R');
const O = new Key('O');
const V = new Key('v');
const e = new Key('e', ['hash256']);
const h = new Key('h', ['hash256']);
const H = new Key('H', ['uint32']);
const n = new Key('n', ['hash256']);
const p = new Key('p', ['hash256']);
const b = new Key('b', ['hash256']);
const t = new Key('t', ['hash256']);
const c = new Key('c', ['hash256', 'uint32']);
const u = new Key('u', ['hash256']);
const v = new Key('v', ['uint8', 'hash256']);
const T160 = new Key('T', ['hash160', 'hash256']);
const T256 = new Key(0xab, ['hash256', 'hash256']);
const C160 = new Key('C', ['hash160', 'hash256', 'uint32']);
const C256 = new Key(0x9a, ['hash256', 'hash256', 'uint32']);
const layout = {
binary: true,
R: Buffer.from([0x52]),
O: Buffer.from([0x4f]),
V: Buffer.from([0x76]),
e: function e(hash) {
return pair(0x65, hash);
},
h: function h(hash) {
return pair(0x68, hash);
},
H: function H(height) {
return ipair(0x48, height);
},
n: function n(hash) {
return pair(0x6e, hash);
},
p: function p(hash) {
return pair(0x70, hash);
},
b: function b(hash) {
return pair(0x62, hash);
},
t: function t(hash) {
return pair(0x74, hash);
},
c: function c(hash, index) {
return bpair(0x63, hash, index);
},
u: function u(hash) {
return pair(0x75, hash);
},
v: function v(bit, hash) {
const key = Buffer.allocUnsafe(1 + 1 + 32);
assert(typeof bit === 'number');
key[0] = 0x76;
key[1] = bit;
write(key, hash, 2);
return key;
},
vv: function vv(key) {
assert(Buffer.isBuffer(key));
assert(key.length === 34);
return [key[1], key.toString('hex', 2, 34)];
},
R: R.build.bind(R),
O: O.build.bind(O),
V: V.build.bind(V),
e: e.build.bind(e),
h: h.build.bind(h),
H: H.build.bind(H),
n: n.build.bind(n),
p: p.build.bind(p),
pp: p.parse.bind(p),
b: b.build.bind(b),
t: t.build.bind(t),
c: c.build.bind(c),
u: u.build.bind(u),
v: v.build.bind(v),
vv: v.parse.bind(v),
T: function T(addr, hash) {
let len = addr.length;
let len = addr ? addr.length : 0;
if (typeof addr === 'string')
len /= 2;
let key;
if (len === 32) {
key = Buffer.allocUnsafe(65);
key[0] = 0xab; // W + T
write(key, addr, 1);
write(key, hash, 33);
} else if (len === 20) {
key = Buffer.allocUnsafe(53);
key[0] = 0x54; // T
write(key, addr, 1);
write(key, hash, 21);
} else {
assert(false);
}
return key;
},
C: function C(addr, hash, index) {
let len = addr.length;
assert(typeof index === 'number');
if (typeof addr === 'string')
len /= 2;
let key;
if (len === 32) {
key = Buffer.allocUnsafe(69);
key[0] = 0x9a; // W + C
write(key, addr, 1);
write(key, hash, 33);
key.writeUInt32BE(index, 65, true);
} else if (len === 20) {
key = Buffer.allocUnsafe(57);
key[0] = 0x43; // C
write(key, addr, 1);
write(key, hash, 21);
key.writeUInt32BE(index, 53, true);
} else {
assert(false);
}
return key;
},
pp: function pp(key) {
assert(Buffer.isBuffer(key));
assert(key.length === 33);
return key.toString('hex', 1, 33);
},
Cc: function Cc(key) {
assert(Buffer.isBuffer(key));
let hash, index;
if (key.length === 69) {
hash = key.toString('hex', 33, 65);
index = key.readUInt32BE(65, 0);
} else if (key.length === 57) {
hash = key.toString('hex', 21, 53);
index = key.readUInt32BE(53, 0);
} else {
assert(false);
}
return [hash, index];
len >>>= 1;
if (len === 32)
return T256.build(addr, hash);
return T160.build(addr, hash);
},
Tt: function Tt(key) {
assert(Buffer.isBuffer(key));
if (key.length === 65)
return key.toString('hex', 33, 65);
assert(key.length === 53);
return key.toString('hex', 21, 53);
if (key && key[0] === 0xab)
return T256.parse(key);
return T160.parse(key);
},
C: function C(addr, hash, index) {
let len = addr ? addr.length : 0;
if (typeof addr === 'string')
len >>>= 1;
if (len === 32)
return C256.build(addr, hash, index);
return C160.build(addr, hash, index);
},
Cc: function Cc(key) {
if (key && key[0] === 0x9a)
return C256.parse(key);
return C160.parse(key);
}
};
/*
* Helpers
*/
function write(data, str, off) {
if (Buffer.isBuffer(str))
return str.copy(data, off);
assert(typeof str === 'string');
return data.write(str, off, 'hex');
}
function pair(prefix, hash) {
const key = Buffer.allocUnsafe(33);
key[0] = prefix;
write(key, hash, 1);
return key;
}
function ipair(prefix, num) {
const key = Buffer.allocUnsafe(5);
assert(typeof num === 'number');
key[0] = prefix;
key.writeUInt32BE(num, 1, true);
return key;
}
function bpair(prefix, hash, index) {
const key = Buffer.allocUnsafe(37);
assert(typeof index === 'number');
key[0] = prefix;
write(key, hash, 1);
key.writeUInt32BE(index, 33, true);
return key;
}
/*
* Expose
*/

View File

@ -7,6 +7,7 @@
'use strict';
const assert = require('assert');
const Key = require('bdb/lib/key');
/*
* Database Layout:
@ -15,35 +16,20 @@ const assert = require('assert');
* e[id][hash] -> entry
*/
const R = new Key('R');
const V = new Key('v');
const F = new Key('F');
const e = new Key('e', ['hash256']);
const layout = {
binary: true,
R: Buffer.from([0x52]),
V: Buffer.from([0x76]),
F: Buffer.from([0x46]),
e: function e(hash) {
const key = Buffer.allocUnsafe(33);
key[0] = 0x65;
write(key, hash, 1);
return key;
},
ee: function ee(key) {
assert(Buffer.isBuffer(key));
assert(key.length === 33);
return key.toString('hex', 1, 33);
}
R: R.build.bind(R),
V: V.build.bind(V),
F: F.build.bind(F),
e: e.build.bind(e),
ee: e.parse.bind(e)
};
/*
* Helpers
*/
function write(data, str, off) {
if (Buffer.isBuffer(str))
return str.copy(data, off);
assert(typeof str === 'string');
return data.write(str, off, 'hex');
}
/*
* Expose
*/

View File

@ -9,6 +9,8 @@
const assert = require('assert');
const layouts = exports;
const Key = require('bdb/lib/key');
/*
* Wallet Database Layout:
* p[addr-hash] -> wallet ids
@ -27,156 +29,46 @@ const layouts = exports;
* T[hash] -> tx->wid map
*/
const p = new Key('p', ['hash']);
const P = new Key('P', ['uint32', 'hash']);
const r = new Key('r', ['uint32', 'uint32', 'hash']);
const w = new Key('w', ['uint32']);
const l = new Key('l', ['ascii']);
const a = new Key('a', ['uint32', 'uint32']);
const i = new Key('i', ['uint32', 'ascii']);
const n = new Key('n', ['uint32', 'uint32']);
const R = new Key('R');
const h = new Key('h', ['uint32']);
const b = new Key('b', ['uint32']);
const o = new Key('o', ['hash256', 'uint32']);
const T = new Key('T', ['hash256']);
// Pp
// rr
layouts.walletdb = {
binary: true,
p: function p(hash) {
assert(typeof hash === 'string');
const key = Buffer.allocUnsafe(1 + (hash.length / 2));
key[0] = 0x70;
key.write(hash, 1, 'hex');
return key;
},
pp: function pp(key) {
assert(Buffer.isBuffer(key));
assert(key.length >= 21);
return key.toString('hex', 1);
},
P: function P(wid, hash) {
assert(typeof wid === 'number');
assert(typeof hash === 'string');
const key = Buffer.allocUnsafe(1 + 4 + (hash.length / 2));
key[0] = 0x50;
key.writeUInt32BE(wid, 1, true);
key.write(hash, 5, 'hex');
return key;
},
Pp: function Pp(key) {
assert(Buffer.isBuffer(key));
assert(key.length >= 25);
return key.toString('hex', 5);
},
r: function r(wid, index, hash) {
assert(typeof wid === 'number');
assert(typeof index === 'number');
assert(typeof hash === 'string');
const key = Buffer.allocUnsafe(1 + 4 + 4 + (hash.length / 2));
key[0] = 0x72;
key.writeUInt32BE(wid, 1, true);
key.writeUInt32BE(index, 5, true);
key.write(hash, 9, 'hex');
return key;
},
rr: function rr(key) {
assert(Buffer.isBuffer(key));
assert(key.length >= 29);
return key.toString('hex', 9);
},
w: function w(wid) {
assert(typeof wid === 'number');
const key = Buffer.allocUnsafe(5);
key[0] = 0x77;
key.writeUInt32BE(wid, 1, true);
return key;
},
ww: function ww(key) {
assert(Buffer.isBuffer(key));
assert(key.length === 5);
return key.readUInt32BE(1, true);
},
l: function l(id) {
assert(typeof id === 'string');
const len = Buffer.byteLength(id, 'ascii');
const key = Buffer.allocUnsafe(1 + len);
key[0] = 0x6c;
if (len > 0)
key.write(id, 1, 'ascii');
return key;
},
ll: function ll(key) {
assert(Buffer.isBuffer(key));
assert(key.length >= 1);
return key.toString('ascii', 1);
},
a: function a(wid, index) {
assert(typeof wid === 'number');
assert(typeof index === 'number');
const key = Buffer.allocUnsafe(9);
key[0] = 0x61;
key.writeUInt32BE(wid, 1, true);
key.writeUInt32BE(index, 5, true);
return key;
},
i: function i(wid, name) {
assert(typeof wid === 'number');
assert(typeof name === 'string');
const len = Buffer.byteLength(name, 'ascii');
const key = Buffer.allocUnsafe(5 + len);
key[0] = 0x69;
key.writeUInt32BE(wid, 1, true);
if (len > 0)
key.write(name, 5, 'ascii');
return key;
},
ii: function ii(key) {
assert(Buffer.isBuffer(key));
assert(key.length >= 5);
return [key.readUInt32BE(1, true), key.toString('ascii', 5)];
},
n: function n(wid, index) {
assert(typeof wid === 'number');
assert(typeof index === 'number');
const key = Buffer.allocUnsafe(9);
key[0] = 0x6e;
key.writeUInt32BE(wid, 1, true);
key.writeUInt32BE(index, 5, true);
return key;
},
R: Buffer.from([0x52]),
h: function h(height) {
assert(typeof height === 'number');
const key = Buffer.allocUnsafe(5);
key[0] = 0x68;
key.writeUInt32BE(height, 1, true);
return key;
},
b: function b(height) {
assert(typeof height === 'number');
const key = Buffer.allocUnsafe(5);
key[0] = 0x62;
key.writeUInt32BE(height, 1, true);
return key;
},
bb: function bb(key) {
assert(Buffer.isBuffer(key));
assert(key.length === 5);
return key.readUInt32BE(1, true);
},
o: function o(hash, index) {
assert(typeof hash === 'string');
assert(typeof index === 'number');
const key = Buffer.allocUnsafe(37);
key[0] = 0x6f;
key.write(hash, 1, 'hex');
key.writeUInt32BE(index, 33, true);
return key;
},
oo: function oo(key) {
assert(Buffer.isBuffer(key));
assert(key.length === 37);
return [key.toString('hex', 1, 33), key.readUInt32BE(33, true)];
},
T: function T(hash, index) {
assert(typeof hash === 'string');
const key = Buffer.allocUnsafe(33);
key[0] = 0x54;
key.write(hash, 1, 'hex');
return key;
},
Tt: function Tt(key) {
assert(Buffer.isBuffer(key));
assert(key.length === 33);
return key.toString('hex', 1, 33);
}
p: p.build.bind(p),
pp: p.parse.bind(p),
P: P.build.bind(P),
Pp: P.parse.bind(P),
r: r.build.bind(r),
rr: r.parse.bind(r),
w: w.build.bind(w),
ww: w.parse.bind(w),
l: l.build.bind(l),
ll: l.parse.bind(l),
a: a.build.bind(a),
i: i.build.bind(i),
ii: i.parse.bind(i),
n: n.build.bind(n),
R: R.build.bind(R),
h: h.build.bind(h),
b: b.build.bind(b),
bb: b.parse.bind(b),
o: o.build.bind(o),
oo: o.parse.bind(o),
T: T.build.bind(T),
Tt: T.parse.bind(T)
};
/*
@ -196,190 +88,55 @@ layouts.walletdb = {
* r[hash] -> dummy (replace by fee chain)
*/
{
const prefix = new Key('t', ['uint32']);
const R = new Key('R');
const r = new Key('r', ['uint32']);
const t = new Key('t', ['hash256']);
const c = new Key('c', ['hash256', 'uint32']);
const d = new Key('d', ['hash256', 'uint32']);
const s = new Key('s', ['hash256', 'uint32']);
const p = new Key('p', ['hash256']);
const m = new Key('m', ['uint32', 'hash256']);
const h = new Key('h', ['uint32', 'hash256']);
const T = new Key('T', ['uint32', 'hash256']);
const P = new Key('P', ['uint32', 'hash256']);
const M = new Key('M', ['uint32', 'uint32', 'hash256']);
const H = new Key('H', ['uint32', 'uint32', 'hash256']);
const C = new Key('C', ['uint32', 'hash256', 'uint32']);
const b = new Key('b', ['uint32']);
layouts.txdb = {
binary: true,
prefix: function prefix(wid) {
assert(typeof wid === 'number');
const out = Buffer.allocUnsafe(5);
out[0] = 0x74;
out.writeUInt32BE(wid, 1);
return out;
},
R: Buffer.from([0x52]),
r: function r(acct) {
assert(typeof acct === 'number');
const key = Buffer.allocUnsafe(5);
key[0] = 0x72;
key.writeUInt32BE(acct, 1, true);
return key;
},
rr: function rr(key) {
assert(Buffer.isBuffer(key));
assert(key.length === 5);
return key.readUInt32BE(1, true);
},
hi: function hi(ch, hash, index) {
assert(typeof hash === 'string');
assert(typeof index === 'number');
const key = Buffer.allocUnsafe(37);
key[0] = ch;
key.write(hash, 1, 'hex');
key.writeUInt32BE(index, 33, true);
return key;
},
hii: function hii(key) {
assert(Buffer.isBuffer(key));
assert(key.length === 37);
return [key.toString('hex', 1, 33), key.readUInt32BE(33, true)];
},
ih: function ih(ch, index, hash) {
assert(typeof index === 'number');
assert(typeof hash === 'string');
const key = Buffer.allocUnsafe(37);
key[0] = ch;
key.writeUInt32BE(index, 1, true);
key.write(hash, 5, 'hex');
return key;
},
ihh: function ihh(key) {
assert(Buffer.isBuffer(key));
assert(key.length === 37);
return [key.readUInt32BE(1, true), key.toString('hex', 5, 37)];
},
iih: function iih(ch, index, num, hash) {
assert(typeof index === 'number');
assert(typeof num === 'number');
assert(typeof hash === 'string');
const key = Buffer.allocUnsafe(41);
key[0] = ch;
key.writeUInt32BE(index, 1, true);
key.writeUInt32BE(num, 5, true);
key.write(hash, 9, 'hex');
return key;
},
iihh: function iihh(key) {
assert(Buffer.isBuffer(key));
assert(key.length === 41);
return [
key.readUInt32BE(1, true),
key.readUInt32BE(5, true),
key.toString('hex', 9, 41)
];
},
ihi: function ihi(ch, index, hash, num) {
assert(typeof index === 'number');
assert(typeof hash === 'string');
assert(typeof num === 'number');
const key = Buffer.allocUnsafe(41);
key[0] = ch;
key.writeUInt32BE(index, 1, true);
key.write(hash, 5, 'hex');
key.writeUInt32BE(num, 37, true);
return key;
},
ihii: function ihii(key) {
assert(Buffer.isBuffer(key));
assert(key.length === 41);
return [
key.readUInt32BE(1, true),
key.toString('hex', 5, 37),
key.readUInt32BE(37, true)
];
},
ha: function ha(ch, hash) {
assert(typeof hash === 'string');
const key = Buffer.allocUnsafe(33);
key[0] = ch;
key.write(hash, 1, 'hex');
return key;
},
haa: function haa(key) {
assert(Buffer.isBuffer(key));
assert(key.length === 33);
return key.toString('hex', 1, 33);
},
t: function t(hash) {
return this.ha(0x74, hash);
},
tt: function tt(key) {
return this.haa(key);
},
c: function c(hash, index) {
return this.hi(0x63, hash, index);
},
cc: function cc(key) {
return this.hii(key);
},
d: function d(hash, index) {
return this.hi(0x64, hash, index);
},
dd: function dd(key) {
return this.hii(key);
},
s: function s(hash, index) {
return this.hi(0x73, hash, index);
},
ss: function ss(key) {
return this.hii(key);
},
p: function p(hash) {
return this.ha(0x70, hash);
},
pp: function pp(key) {
return this.haa(key);
},
m: function m(time, hash) {
return this.ih(0x6d, time, hash);
},
mm: function mm(key) {
return this.ihh(key);
},
h: function h(height, hash) {
return this.ih(0x68, height, hash);
},
hh: function hh(key) {
return this.ihh(key);
},
T: function T(account, hash) {
return this.ih(0x54, account, hash);
},
Tt: function Tt(key) {
return this.ihh(key);
},
P: function P(account, hash) {
return this.ih(0x50, account, hash);
},
Pp: function Pp(key) {
return this.ihh(key);
},
M: function M(account, time, hash) {
return this.iih(0x4d, account, time, hash);
},
Mm: function Mm(key) {
return this.iihh(key);
},
H: function H(account, height, hash) {
return this.iih(0x48, account, height, hash);
},
Hh: function Hh(key) {
return this.iihh(key);
},
C: function C(account, hash, index) {
return this.ihi(0x43, account, hash, index);
},
Cc: function Cc(key) {
return this.ihii(key);
},
b: function b(height) {
assert(typeof height === 'number');
const key = Buffer.allocUnsafe(5);
key[0] = 0x62;
key.writeUInt32BE(height, 1, true);
return key;
},
bb: function bb(key) {
assert(Buffer.isBuffer(key));
assert(key.length === 5);
return key.readUInt32BE(1, true);
}
prefix: prefix.build.bind(prefix),
R: R.build.bind(R),
r: r.build.bind(r),
rr: r.parse.bind(r),
t: t.build.bind(t),
tt: t.parse.bind(t),
c: c.build.bind(c),
cc: c.parse.bind(c),
d: d.build.bind(d),
dd: d.parse.bind(d),
s: s.build.bind(s),
ss: s.parse.bind(s),
p: p.build.bind(p),
pp: p.parse.bind(p),
m: m.build.bind(m),
mm: m.parse.bind(m),
h: h.build.bind(h),
hh: h.parse.bind(h),
T: T.build.bind(T),
Tt: T.parse.bind(T),
P: P.build.bind(P),
Pp: P.parse.bind(P),
M: M.build.bind(M),
Mm: M.parse.bind(M),
H: H.build.bind(H),
Hh: H.parse.bind(H),
C: C.build.bind(C),
Cc: C.parse.bind(C),
b: b.build.bind(b),
bb: b.parse.bind(b)
};
}

View File

@ -187,7 +187,7 @@ class TXDB {
async updateBalance(b, state) {
const balance = await this.getWalletBalance();
state.applyTo(balance);
b.put(layout.R, balance.toRaw());
b.put(layout.R(), balance.toRaw());
return balance;
}
@ -1970,7 +1970,7 @@ class TXDB {
*/
async getWalletBalance() {
const data = await this.bucket.get(layout.R);
const data = await this.bucket.get(layout.R());
if (!data)
return new Balance();

View File

@ -339,7 +339,7 @@ class WalletDB extends EventEmitter {
state.height = tip.height;
state.marked = false;
b.put(layout.R, state.toRaw());
b.put(layout.R(), state.toRaw());
await b.write();
@ -864,7 +864,7 @@ class WalletDB extends EventEmitter {
});
await piter.each((key, value) => {
const hash = layout.Pp(key);
const [, hash] = layout.Pp(key);
b.del(key);
return this.removePathMap(b, hash, wid);
});
@ -1253,7 +1253,7 @@ class WalletDB extends EventEmitter {
return this.db.keys({
gte: layout.P(wid, encoding.NULL_HASH),
lte: layout.P(wid, encoding.HIGH_HASH),
parse: layout.Pp
parse: key => layout.Pp(key)[1]
});
}
@ -1268,7 +1268,7 @@ class WalletDB extends EventEmitter {
return this.db.keys({
gte: layout.r(wid, account, encoding.NULL_HASH),
lte: layout.r(wid, account, encoding.HIGH_HASH),
parse: layout.rr
parse: key => layout.rr(key)[2]
});
}
@ -1287,7 +1287,7 @@ class WalletDB extends EventEmitter {
const paths = [];
for (const item of items) {
const hash = layout.Pp(item.key);
const [, hash] = layout.Pp(item.key);
const path = Path.fromRaw(item.value);
path.hash = hash;
@ -1328,7 +1328,7 @@ class WalletDB extends EventEmitter {
});
await iter.each((k, value) => {
const hash = layout.Pp(k);
const [, hash] = layout.Pp(k);
const path = Path.fromRaw(value);
if (!path.data)
@ -1361,7 +1361,7 @@ class WalletDB extends EventEmitter {
});
await iter.each((k, value) => {
const hash = layout.Pp(k);
const [, hash] = layout.Pp(k);
const path = Path.fromRaw(value);
if (!path.data)
@ -1388,7 +1388,7 @@ class WalletDB extends EventEmitter {
const wids = await this.db.keys({
gte: layout.w(0x00000000),
lte: layout.w(0xffffffff),
parse: k => layout.ww(k)
parse: key => layout.ww(key)
});
this.logger.info('Resending from %d wallets.', wids.length);
@ -1412,7 +1412,7 @@ class WalletDB extends EventEmitter {
const hashes = await b.keys({
gte: layout.p(encoding.NULL_HASH),
lte: layout.p(encoding.HIGH_HASH),
parse: k => layout.pp(k)
parse: key => layout.pp(key)
});
if (hashes.length === 0)
@ -1496,7 +1496,7 @@ class WalletDB extends EventEmitter {
*/
async getState() {
const data = await this.db.get(layout.R);
const data = await this.db.get(layout.R());
if (!data)
return null;
@ -1534,7 +1534,7 @@ class WalletDB extends EventEmitter {
// Save tip and state.
b.put(layout.h(tip.height), tip.toHash());
b.put(layout.R, state.toRaw());
b.put(layout.R(), state.toRaw());
await b.write();
@ -1555,7 +1555,7 @@ class WalletDB extends EventEmitter {
state.marked = true;
const b = this.db.batch();
b.put(layout.R, state.toRaw());
b.put(layout.R(), state.toRaw());
await b.write();
this.state = state;