walletdb: better wallet commits.

This commit is contained in:
Christopher Jeffrey 2016-10-23 13:44:07 -07:00
parent b98ca596d1
commit 45816e4527
No known key found for this signature in database
GPG Key ID: 8962AB9DE6666BBD

View File

@ -421,9 +421,18 @@ WalletDB.prototype.batch = function batch(wallet) {
*/
WalletDB.prototype.commit = co(function* commit(wallet) {
var batch = wallet.current;
var batch = this.batch(wallet);
try {
yield batch.write();
} catch (e) {
wallet.current = null;
wallet.accountCache.drop();
wallet.pathCache.drop();
throw e;
}
wallet.current = null;
yield batch.write();
wallet.accountCache.commit();
wallet.pathCache.commit();
});