account: remove change lookahead.

This commit is contained in:
Christopher Jeffrey 2016-11-02 17:08:15 -07:00
parent 7d3eb8f3fa
commit f1f5a2e5d3
No known key found for this signature in database
GPG Key ID: 8962AB9DE6666BBD

View File

@ -452,9 +452,9 @@ Account.prototype.createKey = co(function* createKey(branch) {
this.receive = key;
break;
case 1:
// Note: no lookahead here.
key = this.deriveChange(this.changeDepth);
lookahead = this.deriveChange(this.changeDepth + this.lookahead);
yield this.saveKey(lookahead);
yield this.saveKey(key);
this.changeDepth++;
this.change = key;
break;
@ -626,7 +626,13 @@ Account.prototype.initDepth = co(function* initDepth() {
yield this.saveKey(this.receive);
// Change Address
// Lookahead
for (i = 0; i < this.lookahead; i++) {
key = this.deriveReceive(i + 1);
yield this.saveKey(key);
}
// Change Address (no lookahead)
this.change = this.deriveChange(0);
this.changeDepth = 1;
@ -638,20 +644,8 @@ Account.prototype.initDepth = co(function* initDepth() {
this.nestedDepth = 1;
yield this.saveKey(this.nested);
}
// Lookaheads
for (i = 0; i < this.lookahead; i++) {
key = this.deriveReceive(i + 1);
yield this.saveKey(key);
}
for (i = 0; i < this.lookahead; i++) {
key = this.deriveChange(i + 1);
yield this.saveKey(key);
}
if (this.witness) {
// Lookahead
for (i = 0; i < this.lookahead; i++) {
key = this.deriveNested(i + 1);
yield this.saveKey(key);
@ -677,7 +671,7 @@ Account.prototype.syncDepth = co(function* syncDepth(receive, change, nested) {
if (receive > this.receiveDepth) {
depth = this.receiveDepth + this.lookahead;
assert(receive <= depth);
assert(this.lookahead === 0 || receive <= depth);
for (i = depth; i < receive + this.lookahead; i++) {
key = this.deriveReceive(i);
@ -692,14 +686,10 @@ Account.prototype.syncDepth = co(function* syncDepth(receive, change, nested) {
}
if (change > this.changeDepth) {
depth = this.changeDepth + this.lookahead;
assert(change === this.changeDepth + 1);
assert(change <= depth);
for (i = depth; i < change + this.lookahead; i++) {
key = this.deriveChange(i);
yield this.saveKey(key);
}
key = this.deriveChange(change - 1);
yield this.saveKey(key);
this.change = this.deriveChange(change - 1);
this.changeDepth = change;
@ -710,7 +700,7 @@ Account.prototype.syncDepth = co(function* syncDepth(receive, change, nested) {
if (this.witness && nested > this.nestedDepth) {
depth = this.nestedDepth + this.lookahead;
assert(nested <= depth);
assert(this.lookahead === 0 || nested <= depth);
for (i = depth; i < nested + this.lookahead; i++) {
key = this.deriveNested(i);