walletdb: add startHeight option.

This commit is contained in:
Christopher Jeffrey 2016-11-02 04:40:26 -07:00
parent b2c02a7052
commit 666e7d514f
No known key found for this signature in database
GPG Key ID: 8962AB9DE6666BBD
4 changed files with 10 additions and 1 deletions

View File

@ -210,6 +210,7 @@ config.parseData = function parseData(data, prefix, dirname) {
options.noAuth = bool(data.noauth);
// Wallet
options.startHeight = num(data.startheight);
options.wipeNoReally = bool(data.wipenoreally);
options.data = data;

View File

@ -148,6 +148,7 @@ function FullNode(options) {
witness: this.options.witness,
useCheckpoints: this.options.useCheckpoints,
maxFiles: this.options.maxFiles,
startHeight: this.options.startHeight,
wipeNoReally: this.options.wipeNoReally,
resolution: false,
verify: false

View File

@ -88,6 +88,7 @@ function SPVNode(options) {
location: this.location('walletdb'),
witness: this.options.witness,
maxFiles: this.options.maxFiles,
startHeight: this.options.startHeight,
wipeNoReally: this.options.wipeNoReally,
resolution: true,
verify: true

View File

@ -1535,7 +1535,13 @@ WalletDB.prototype.init = co(function* init() {
}
if (this.client) {
tip = yield this.client.getTip();
if (this.options.startHeight != null) {
tip = yield this.client.getEntry(this.options.startHeight);
if (!tip)
throw new Error('WDB: Could not find start block.');
} else {
tip = yield this.client.getTip();
}
tip = BlockMeta.fromEntry(tip);
} else {
tip = BlockMeta.fromEntry(this.network.genesis);