From 4cb11da4cf6e76cc5f0ac2fac31fc680ed732f2f Mon Sep 17 00:00:00 2001 From: Christopher Jeffrey Date: Mon, 7 Nov 2016 21:46:15 -0800 Subject: [PATCH] walletdb: safe sync option. --- lib/wallet/wallet.js | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/lib/wallet/wallet.js b/lib/wallet/wallet.js index 6439dddc..bae75cb2 100644 --- a/lib/wallet/wallet.js +++ b/lib/wallet/wallet.js @@ -1857,12 +1857,17 @@ Wallet.prototype._setLookahead = co(function* setLookahead(acct, lookahead) { Wallet.prototype.syncOutputDepth = co(function* syncOutputDepth(details) { var derived = []; var accounts = {}; - var i, j, path, paths, account; + var i, j, path, paths, acct, account; var receive, change, nested, ring; if (!details) return derived; + if (this.db.options.safeSync) { + if (details.height === -1) + return; + } + for (i = 0; i < details.outputs.length; i++) { path = details.outputs[i].path; @@ -1882,7 +1887,7 @@ Wallet.prototype.syncOutputDepth = co(function* syncOutputDepth(details) { for (i = 0; i < accounts.length; i++) { paths = accounts[i]; - account = paths[0].account; + acct = paths[0].account; receive = -1; change = -1; nested = -1; @@ -1910,10 +1915,8 @@ Wallet.prototype.syncOutputDepth = co(function* syncOutputDepth(details) { change += 2; nested += 2; - account = yield this.getAccount(account); - - if (!account) - continue; + account = yield this.getAccount(acct); + assert(account); ring = yield account.syncDepth(receive, change, nested);