From 666e7d514f25fc631245ec348b3b30416d6aa622 Mon Sep 17 00:00:00 2001 From: Christopher Jeffrey Date: Wed, 2 Nov 2016 04:40:26 -0700 Subject: [PATCH] walletdb: add startHeight option. --- lib/node/config.js | 1 + lib/node/fullnode.js | 1 + lib/node/spvnode.js | 1 + lib/wallet/walletdb.js | 8 +++++++- 4 files changed, 10 insertions(+), 1 deletion(-) diff --git a/lib/node/config.js b/lib/node/config.js index 6f178d2b..fde5c984 100644 --- a/lib/node/config.js +++ b/lib/node/config.js @@ -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; diff --git a/lib/node/fullnode.js b/lib/node/fullnode.js index a1de516b..445fe3f7 100644 --- a/lib/node/fullnode.js +++ b/lib/node/fullnode.js @@ -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 diff --git a/lib/node/spvnode.js b/lib/node/spvnode.js index be9e34ef..7dc33a1a 100644 --- a/lib/node/spvnode.js +++ b/lib/node/spvnode.js @@ -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 diff --git a/lib/wallet/walletdb.js b/lib/wallet/walletdb.js index 009132ca..b55bd847 100644 --- a/lib/wallet/walletdb.js +++ b/lib/wallet/walletdb.js @@ -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);