wallet: fix layout style.
This commit is contained in:
parent
f58feb0035
commit
1f38f36077
@ -29,8 +29,8 @@ const layouts = exports;
|
|||||||
layouts.walletdb = {
|
layouts.walletdb = {
|
||||||
binary: true,
|
binary: true,
|
||||||
p: function p(hash) {
|
p: function p(hash) {
|
||||||
const key = Buffer.allocUnsafe(1 + (hash.length / 2));
|
|
||||||
assert(typeof hash === 'string');
|
assert(typeof hash === 'string');
|
||||||
|
const key = Buffer.allocUnsafe(1 + (hash.length / 2));
|
||||||
key[0] = 0x70;
|
key[0] = 0x70;
|
||||||
key.write(hash, 1, 'hex');
|
key.write(hash, 1, 'hex');
|
||||||
return key;
|
return key;
|
||||||
@ -41,9 +41,9 @@ layouts.walletdb = {
|
|||||||
return key.toString('hex', 1);
|
return key.toString('hex', 1);
|
||||||
},
|
},
|
||||||
P: function P(wid, hash) {
|
P: function P(wid, hash) {
|
||||||
const key = Buffer.allocUnsafe(1 + 4 + (hash.length / 2));
|
|
||||||
assert(typeof wid === 'number');
|
assert(typeof wid === 'number');
|
||||||
assert(typeof hash === 'string');
|
assert(typeof hash === 'string');
|
||||||
|
const key = Buffer.allocUnsafe(1 + 4 + (hash.length / 2));
|
||||||
key[0] = 0x50;
|
key[0] = 0x50;
|
||||||
key.writeUInt32BE(wid, 1, true);
|
key.writeUInt32BE(wid, 1, true);
|
||||||
key.write(hash, 5, 'hex');
|
key.write(hash, 5, 'hex');
|
||||||
@ -55,10 +55,10 @@ layouts.walletdb = {
|
|||||||
return key.toString('hex', 5);
|
return key.toString('hex', 5);
|
||||||
},
|
},
|
||||||
r: function r(wid, index, hash) {
|
r: function r(wid, index, hash) {
|
||||||
const key = Buffer.allocUnsafe(1 + 4 + 4 + (hash.length / 2));
|
|
||||||
assert(typeof wid === 'number');
|
assert(typeof wid === 'number');
|
||||||
assert(typeof index === 'number');
|
assert(typeof index === 'number');
|
||||||
assert(typeof hash === 'string');
|
assert(typeof hash === 'string');
|
||||||
|
const key = Buffer.allocUnsafe(1 + 4 + 4 + (hash.length / 2));
|
||||||
key[0] = 0x72;
|
key[0] = 0x72;
|
||||||
key.writeUInt32BE(wid, 1, true);
|
key.writeUInt32BE(wid, 1, true);
|
||||||
key.writeUInt32BE(index, 5, true);
|
key.writeUInt32BE(index, 5, true);
|
||||||
@ -71,8 +71,8 @@ layouts.walletdb = {
|
|||||||
return key.toString('hex', 9);
|
return key.toString('hex', 9);
|
||||||
},
|
},
|
||||||
w: function w(wid) {
|
w: function w(wid) {
|
||||||
const key = Buffer.allocUnsafe(5);
|
|
||||||
assert(typeof wid === 'number');
|
assert(typeof wid === 'number');
|
||||||
|
const key = Buffer.allocUnsafe(5);
|
||||||
key[0] = 0x77;
|
key[0] = 0x77;
|
||||||
key.writeUInt32BE(wid, 1, true);
|
key.writeUInt32BE(wid, 1, true);
|
||||||
return key;
|
return key;
|
||||||
@ -83,9 +83,9 @@ layouts.walletdb = {
|
|||||||
return key.readUInt32BE(1, true);
|
return key.readUInt32BE(1, true);
|
||||||
},
|
},
|
||||||
l: function l(id) {
|
l: function l(id) {
|
||||||
|
assert(typeof id === 'string');
|
||||||
const len = Buffer.byteLength(id, 'ascii');
|
const len = Buffer.byteLength(id, 'ascii');
|
||||||
const key = Buffer.allocUnsafe(1 + len);
|
const key = Buffer.allocUnsafe(1 + len);
|
||||||
assert(typeof id === 'string');
|
|
||||||
key[0] = 0x6c;
|
key[0] = 0x6c;
|
||||||
if (len > 0)
|
if (len > 0)
|
||||||
key.write(id, 1, 'ascii');
|
key.write(id, 1, 'ascii');
|
||||||
@ -97,19 +97,19 @@ layouts.walletdb = {
|
|||||||
return key.toString('ascii', 1);
|
return key.toString('ascii', 1);
|
||||||
},
|
},
|
||||||
a: function a(wid, index) {
|
a: function a(wid, index) {
|
||||||
const key = Buffer.allocUnsafe(9);
|
|
||||||
assert(typeof wid === 'number');
|
assert(typeof wid === 'number');
|
||||||
assert(typeof index === 'number');
|
assert(typeof index === 'number');
|
||||||
|
const key = Buffer.allocUnsafe(9);
|
||||||
key[0] = 0x61;
|
key[0] = 0x61;
|
||||||
key.writeUInt32BE(wid, 1, true);
|
key.writeUInt32BE(wid, 1, true);
|
||||||
key.writeUInt32BE(index, 5, true);
|
key.writeUInt32BE(index, 5, true);
|
||||||
return key;
|
return key;
|
||||||
},
|
},
|
||||||
i: function i(wid, name) {
|
i: function i(wid, name) {
|
||||||
const len = Buffer.byteLength(name, 'ascii');
|
|
||||||
const key = Buffer.allocUnsafe(5 + len);
|
|
||||||
assert(typeof wid === 'number');
|
assert(typeof wid === 'number');
|
||||||
assert(typeof name === 'string');
|
assert(typeof name === 'string');
|
||||||
|
const len = Buffer.byteLength(name, 'ascii');
|
||||||
|
const key = Buffer.allocUnsafe(5 + len);
|
||||||
key[0] = 0x69;
|
key[0] = 0x69;
|
||||||
key.writeUInt32BE(wid, 1, true);
|
key.writeUInt32BE(wid, 1, true);
|
||||||
if (len > 0)
|
if (len > 0)
|
||||||
@ -122,9 +122,9 @@ layouts.walletdb = {
|
|||||||
return [key.readUInt32BE(1, true), key.toString('ascii', 5)];
|
return [key.readUInt32BE(1, true), key.toString('ascii', 5)];
|
||||||
},
|
},
|
||||||
n: function n(wid, index) {
|
n: function n(wid, index) {
|
||||||
const key = Buffer.allocUnsafe(9);
|
|
||||||
assert(typeof wid === 'number');
|
assert(typeof wid === 'number');
|
||||||
assert(typeof index === 'number');
|
assert(typeof index === 'number');
|
||||||
|
const key = Buffer.allocUnsafe(9);
|
||||||
key[0] = 0x6e;
|
key[0] = 0x6e;
|
||||||
key.writeUInt32BE(wid, 1, true);
|
key.writeUInt32BE(wid, 1, true);
|
||||||
key.writeUInt32BE(index, 5, true);
|
key.writeUInt32BE(index, 5, true);
|
||||||
@ -132,15 +132,15 @@ layouts.walletdb = {
|
|||||||
},
|
},
|
||||||
R: Buffer.from([0x52]),
|
R: Buffer.from([0x52]),
|
||||||
h: function h(height) {
|
h: function h(height) {
|
||||||
const key = Buffer.allocUnsafe(5);
|
|
||||||
assert(typeof height === 'number');
|
assert(typeof height === 'number');
|
||||||
|
const key = Buffer.allocUnsafe(5);
|
||||||
key[0] = 0x68;
|
key[0] = 0x68;
|
||||||
key.writeUInt32BE(height, 1, true);
|
key.writeUInt32BE(height, 1, true);
|
||||||
return key;
|
return key;
|
||||||
},
|
},
|
||||||
b: function b(height) {
|
b: function b(height) {
|
||||||
const key = Buffer.allocUnsafe(5);
|
|
||||||
assert(typeof height === 'number');
|
assert(typeof height === 'number');
|
||||||
|
const key = Buffer.allocUnsafe(5);
|
||||||
key[0] = 0x62;
|
key[0] = 0x62;
|
||||||
key.writeUInt32BE(height, 1, true);
|
key.writeUInt32BE(height, 1, true);
|
||||||
return key;
|
return key;
|
||||||
@ -151,9 +151,9 @@ layouts.walletdb = {
|
|||||||
return key.readUInt32BE(1, true);
|
return key.readUInt32BE(1, true);
|
||||||
},
|
},
|
||||||
o: function o(hash, index) {
|
o: function o(hash, index) {
|
||||||
const key = Buffer.allocUnsafe(37);
|
|
||||||
assert(typeof hash === 'string');
|
assert(typeof hash === 'string');
|
||||||
assert(typeof index === 'number');
|
assert(typeof index === 'number');
|
||||||
|
const key = Buffer.allocUnsafe(37);
|
||||||
key[0] = 0x6f;
|
key[0] = 0x6f;
|
||||||
key.write(hash, 1, 'hex');
|
key.write(hash, 1, 'hex');
|
||||||
key.writeUInt32BE(index, 33, true);
|
key.writeUInt32BE(index, 33, true);
|
||||||
@ -187,9 +187,9 @@ layouts.walletdb = {
|
|||||||
layouts.txdb = {
|
layouts.txdb = {
|
||||||
binary: true,
|
binary: true,
|
||||||
prefix: function prefix(wid, key) {
|
prefix: function prefix(wid, key) {
|
||||||
const out = Buffer.allocUnsafe(5 + key.length);
|
|
||||||
assert(typeof wid === 'number');
|
assert(typeof wid === 'number');
|
||||||
assert(Buffer.isBuffer(key));
|
assert(Buffer.isBuffer(key));
|
||||||
|
const out = Buffer.allocUnsafe(5 + key.length);
|
||||||
out[0] = 0x74;
|
out[0] = 0x74;
|
||||||
out.writeUInt32BE(wid, 1);
|
out.writeUInt32BE(wid, 1);
|
||||||
key.copy(out, 5);
|
key.copy(out, 5);
|
||||||
@ -202,9 +202,9 @@ layouts.txdb = {
|
|||||||
},
|
},
|
||||||
R: Buffer.from([0x52]),
|
R: Buffer.from([0x52]),
|
||||||
hi: function hi(ch, hash, index) {
|
hi: function hi(ch, hash, index) {
|
||||||
const key = Buffer.allocUnsafe(37);
|
|
||||||
assert(typeof hash === 'string');
|
assert(typeof hash === 'string');
|
||||||
assert(typeof index === 'number');
|
assert(typeof index === 'number');
|
||||||
|
const key = Buffer.allocUnsafe(37);
|
||||||
key[0] = ch;
|
key[0] = ch;
|
||||||
key.write(hash, 1, 'hex');
|
key.write(hash, 1, 'hex');
|
||||||
key.writeUInt32BE(index, 33, true);
|
key.writeUInt32BE(index, 33, true);
|
||||||
@ -217,9 +217,9 @@ layouts.txdb = {
|
|||||||
return [key.toString('hex', 0, 32), key.readUInt32BE(32, true)];
|
return [key.toString('hex', 0, 32), key.readUInt32BE(32, true)];
|
||||||
},
|
},
|
||||||
ih: function ih(ch, index, hash) {
|
ih: function ih(ch, index, hash) {
|
||||||
const key = Buffer.allocUnsafe(37);
|
|
||||||
assert(typeof index === 'number');
|
assert(typeof index === 'number');
|
||||||
assert(typeof hash === 'string');
|
assert(typeof hash === 'string');
|
||||||
|
const key = Buffer.allocUnsafe(37);
|
||||||
key[0] = ch;
|
key[0] = ch;
|
||||||
key.writeUInt32BE(index, 1, true);
|
key.writeUInt32BE(index, 1, true);
|
||||||
key.write(hash, 5, 'hex');
|
key.write(hash, 5, 'hex');
|
||||||
@ -232,10 +232,10 @@ layouts.txdb = {
|
|||||||
return [key.readUInt32BE(0, true), key.toString('hex', 4, 36)];
|
return [key.readUInt32BE(0, true), key.toString('hex', 4, 36)];
|
||||||
},
|
},
|
||||||
iih: function iih(ch, index, num, hash) {
|
iih: function iih(ch, index, num, hash) {
|
||||||
const key = Buffer.allocUnsafe(41);
|
|
||||||
assert(typeof index === 'number');
|
assert(typeof index === 'number');
|
||||||
assert(typeof num === 'number');
|
assert(typeof num === 'number');
|
||||||
assert(typeof hash === 'string');
|
assert(typeof hash === 'string');
|
||||||
|
const key = Buffer.allocUnsafe(41);
|
||||||
key[0] = ch;
|
key[0] = ch;
|
||||||
key.writeUInt32BE(index, 1, true);
|
key.writeUInt32BE(index, 1, true);
|
||||||
key.writeUInt32BE(num, 5, true);
|
key.writeUInt32BE(num, 5, true);
|
||||||
@ -253,10 +253,10 @@ layouts.txdb = {
|
|||||||
];
|
];
|
||||||
},
|
},
|
||||||
ihi: function ihi(ch, index, hash, num) {
|
ihi: function ihi(ch, index, hash, num) {
|
||||||
const key = Buffer.allocUnsafe(41);
|
|
||||||
assert(typeof index === 'number');
|
assert(typeof index === 'number');
|
||||||
assert(typeof hash === 'string');
|
assert(typeof hash === 'string');
|
||||||
assert(typeof num === 'number');
|
assert(typeof num === 'number');
|
||||||
|
const key = Buffer.allocUnsafe(41);
|
||||||
key[0] = ch;
|
key[0] = ch;
|
||||||
key.writeUInt32BE(index, 1, true);
|
key.writeUInt32BE(index, 1, true);
|
||||||
key.write(hash, 5, 'hex');
|
key.write(hash, 5, 'hex');
|
||||||
@ -274,8 +274,8 @@ layouts.txdb = {
|
|||||||
];
|
];
|
||||||
},
|
},
|
||||||
ha: function ha(ch, hash) {
|
ha: function ha(ch, hash) {
|
||||||
const key = Buffer.allocUnsafe(33);
|
|
||||||
assert(typeof hash === 'string');
|
assert(typeof hash === 'string');
|
||||||
|
const key = Buffer.allocUnsafe(33);
|
||||||
key[0] = ch;
|
key[0] = ch;
|
||||||
key.write(hash, 1, 'hex');
|
key.write(hash, 1, 'hex');
|
||||||
return key;
|
return key;
|
||||||
@ -362,8 +362,8 @@ layouts.txdb = {
|
|||||||
return this.ha(0x72, hash);
|
return this.ha(0x72, hash);
|
||||||
},
|
},
|
||||||
b: function b(height) {
|
b: function b(height) {
|
||||||
const key = Buffer.allocUnsafe(5);
|
|
||||||
assert(typeof height === 'number');
|
assert(typeof height === 'number');
|
||||||
|
const key = Buffer.allocUnsafe(5);
|
||||||
key[0] = 0x62;
|
key[0] = 0x62;
|
||||||
key.writeUInt32BE(height, 1, true);
|
key.writeUInt32BE(height, 1, true);
|
||||||
return key;
|
return key;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user