walletdb: switch back to lookahead of 10.
This commit is contained in:
parent
93d2c8811f
commit
4fcb07ff5f
@ -67,7 +67,7 @@ function Account(db, options) {
|
|||||||
this.receiveDepth = 0;
|
this.receiveDepth = 0;
|
||||||
this.changeDepth = 0;
|
this.changeDepth = 0;
|
||||||
this.nestedDepth = 0;
|
this.nestedDepth = 0;
|
||||||
this.lookahead = 5;
|
this.lookahead = 10;
|
||||||
this.accountKey = null;
|
this.accountKey = null;
|
||||||
this.keys = [];
|
this.keys = [];
|
||||||
|
|
||||||
@ -441,9 +441,9 @@ Account.prototype.createKey = co(function* createKey(branch) {
|
|||||||
this.receive = key;
|
this.receive = key;
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
// Note: no lookahead here.
|
|
||||||
key = this.deriveChange(this.changeDepth);
|
key = this.deriveChange(this.changeDepth);
|
||||||
yield this.saveKey(key);
|
lookahead = this.deriveReceive(this.changeDepth + this.lookahead);
|
||||||
|
yield this.saveKey(lookahead);
|
||||||
this.changeDepth++;
|
this.changeDepth++;
|
||||||
this.change = key;
|
this.change = key;
|
||||||
break;
|
break;
|
||||||
@ -621,12 +621,18 @@ Account.prototype.initDepth = co(function* initDepth() {
|
|||||||
yield this.saveKey(key);
|
yield this.saveKey(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Change Address (no lookahead)
|
// Change Address
|
||||||
this.change = this.deriveChange(0);
|
this.change = this.deriveChange(0);
|
||||||
this.changeDepth = 1;
|
this.changeDepth = 1;
|
||||||
|
|
||||||
yield this.saveKey(this.change);
|
yield this.saveKey(this.change);
|
||||||
|
|
||||||
|
// Lookahead
|
||||||
|
for (i = 0; i < this.lookahead; i++) {
|
||||||
|
key = this.deriveChange(i + 1);
|
||||||
|
yield this.saveKey(key);
|
||||||
|
}
|
||||||
|
|
||||||
// Nested Address
|
// Nested Address
|
||||||
if (this.witness) {
|
if (this.witness) {
|
||||||
this.nested = this.deriveNested(0);
|
this.nested = this.deriveNested(0);
|
||||||
@ -660,7 +666,7 @@ Account.prototype.syncDepth = co(function* syncDepth(receive, change, nested) {
|
|||||||
if (receive > this.receiveDepth) {
|
if (receive > this.receiveDepth) {
|
||||||
depth = this.receiveDepth + this.lookahead;
|
depth = this.receiveDepth + this.lookahead;
|
||||||
|
|
||||||
assert(this.lookahead === 0 || receive <= depth);
|
assert(receive <= depth + 1);
|
||||||
|
|
||||||
for (i = depth; i < receive + this.lookahead; i++) {
|
for (i = depth; i < receive + this.lookahead; i++) {
|
||||||
key = this.deriveReceive(i);
|
key = this.deriveReceive(i);
|
||||||
@ -675,12 +681,16 @@ Account.prototype.syncDepth = co(function* syncDepth(receive, change, nested) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (change > this.changeDepth) {
|
if (change > this.changeDepth) {
|
||||||
assert(change === this.changeDepth + 1);
|
depth = this.changeDepth + this.lookahead;
|
||||||
|
|
||||||
key = this.deriveChange(change - 1);
|
assert(change <= depth + 1);
|
||||||
yield this.saveKey(key);
|
|
||||||
|
|
||||||
this.change = key;
|
for (i = depth; i < change + this.lookahead; i++) {
|
||||||
|
key = this.deriveChange(i);
|
||||||
|
yield this.saveKey(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.change = this.deriveChange(change - 1);
|
||||||
this.changeDepth = change;
|
this.changeDepth = change;
|
||||||
|
|
||||||
derived = true;
|
derived = true;
|
||||||
@ -689,7 +699,7 @@ Account.prototype.syncDepth = co(function* syncDepth(receive, change, nested) {
|
|||||||
if (this.witness && nested > this.nestedDepth) {
|
if (this.witness && nested > this.nestedDepth) {
|
||||||
depth = this.nestedDepth + this.lookahead;
|
depth = this.nestedDepth + this.lookahead;
|
||||||
|
|
||||||
assert(this.lookahead === 0 || nested <= depth);
|
assert(nested <= depth + 1);
|
||||||
|
|
||||||
for (i = depth; i < nested + this.lookahead; i++) {
|
for (i = depth; i < nested + this.lookahead; i++) {
|
||||||
key = this.deriveNested(i);
|
key = this.deriveNested(i);
|
||||||
|
|||||||
@ -194,10 +194,10 @@ function accountFromRaw(data) {
|
|||||||
account.m = p.readU8();
|
account.m = p.readU8();
|
||||||
account.n = p.readU8();
|
account.n = p.readU8();
|
||||||
account.accountIndex = p.readU32();
|
account.accountIndex = p.readU32();
|
||||||
account.receiveDepth = p.readU32() + 5;
|
account.receiveDepth = p.readU32();
|
||||||
account.changeDepth = p.readU32() + 10;
|
account.changeDepth = p.readU32();
|
||||||
account.nestedDepth = p.readU32() + (account.witness ? 5 : 0);
|
account.nestedDepth = p.readU32();
|
||||||
account.lookahead = 5;
|
account.lookahead = 10;
|
||||||
account.accountKey = p.readBytes(82);
|
account.accountKey = p.readBytes(82);
|
||||||
account.keys = [];
|
account.keys = [];
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user