walletdb: setLookahead.
This commit is contained in:
parent
619143156b
commit
0825007c3d
@ -218,7 +218,7 @@ Account.fromOptions = function fromOptions(db, options) {
|
||||
* @const {Number}
|
||||
*/
|
||||
|
||||
Account.MAX_LOOKAHEAD = 50;
|
||||
Account.MAX_LOOKAHEAD = 40;
|
||||
|
||||
/**
|
||||
* Attempt to intialize the account (generating
|
||||
@ -726,15 +726,36 @@ Account.prototype.syncDepth = co(function* syncDepth(receive, change, nested) {
|
||||
*/
|
||||
|
||||
Account.prototype.setLookahead = co(function* setLookahead(lookahead) {
|
||||
var i, key, depth, target;
|
||||
var i, diff, key, depth, target;
|
||||
|
||||
if (lookahead <= this.lookahead) {
|
||||
if (lookahead === this.lookahead) {
|
||||
this.db.logger.warning(
|
||||
'Lookahead is not increasing for: %s/%s.',
|
||||
'Lookahead is not changing for: %s/%s.',
|
||||
this.id, this.name);
|
||||
return;
|
||||
}
|
||||
|
||||
if (lookahead < this.lookahead) {
|
||||
diff = this.lookahead - lookahead;
|
||||
|
||||
this.receiveDepth += diff;
|
||||
this.receive = this.deriveReceive(this.receiveDepth - 1);
|
||||
|
||||
this.changeDepth += diff;
|
||||
this.change = this.deriveChange(this.changeDepth - 1);
|
||||
|
||||
if (this.witness) {
|
||||
this.nestedDepth += diff;
|
||||
this.nested = this.deriveNested(this.nestedDepth - 1);
|
||||
}
|
||||
|
||||
this.lookahead = lookahead;
|
||||
|
||||
this.save();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
depth = this.receiveDepth + this.lookahead
|
||||
target = this.receiveDepth + lookahead;
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user