This commit is contained in:
Chris Kleeschulte 2017-07-22 20:32:13 -04:00
parent c91155cc35
commit d15d213f7f
3 changed files with 38 additions and 44 deletions

View File

@ -38,7 +38,6 @@ function DB(options) {
this.subscriptions = {};
this._operationsCount = 0;
this.GENESIS_HASH = constants.BITCOIN_GENESIS_HASH[this.node.getNetworkName()];
this.node.on('stopping', function() {
@ -139,10 +138,8 @@ DB.prototype.put = function(key, value, options) {
return;
}
self._operationsCount++;
self._store.put(key, value, options, function(err) {
self._operationsCount--;
if (err) {
self.emit('error', err);
return;
@ -171,11 +168,8 @@ DB.prototype.batch = function(ops, options) {
}
}
self._operationsCount += ops.length;
self._store.batch(ops, options, function(err) {
self._operationsCount -= ops.length;
if (err) {
self.emit('error', err);
return;
@ -214,21 +208,10 @@ DB.prototype.stop = function(callback) {
self.close(callback);
};
// for this to work, p2p service has to close out first
// it is feeding more and more ops
DB.prototype.close = function(callback) {
var self = this;
if (self._store && self._store.isOpen()) {
// wait for pending write events to complete before issuing the close event
async.until(function() {
return self._operationsCount <= 0;
},
function(next) {
setTimeout(next, 1000);
},
function() {
self._store.close(callback);
});
self._store.close(callback);
}
};

61
package-lock.json generated
View File

@ -191,24 +191,52 @@
"integrity": "sha1-R2iMuZu2gE8OBtPnY7HDLlfY5rY="
},
"bcoin": {
"version": "github:bcoin-org/bcoin#ffec8ff2d7e05591d113004ed1aca6e0c4fd1d20",
"version": "github:bcoin-org/bcoin#886008a1822ce1da7fa8395ee7db4bcc1750a28a",
"requires": {
"bcoin-native": "0.0.23",
"bcoin-native": "0.0.20",
"bn.js": "4.11.7",
"elliptic": "6.4.0",
"leveldown": "1.7.2",
"n64": "0.0.12",
"leveldown": "1.7.0-0",
"n64": "0.0.11",
"secp256k1": "3.2.5",
"socket.io": "2.0.1",
"socket.io-client": "2.0.1"
},
"dependencies": {
"bcoin-native": {
"version": "0.0.20",
"resolved": "https://registry.npmjs.org/bcoin-native/-/bcoin-native-0.0.20.tgz",
"integrity": "sha1-zeKTpb1yrk+YXwcTRPDJoWunst0=",
"optional": true,
"requires": {
"bindings": "1.2.1",
"nan": "2.6.2"
}
},
"leveldown": {
"version": "1.7.0-0",
"resolved": "https://registry.npmjs.org/leveldown/-/leveldown-1.7.0-0.tgz",
"integrity": "sha1-orKVMhbsJzrmWkG6bNiNaXn98T8=",
"optional": true,
"requires": {
"abstract-leveldown": "2.6.1",
"bindings": "1.2.1",
"fast-future": "1.0.2",
"nan": "2.6.2",
"prebuild-install": "2.2.0"
}
},
"ms": {
"version": "0.7.3",
"resolved": "https://registry.npmjs.org/ms/-/ms-0.7.3.tgz",
"integrity": "sha1-cIFVpeROM/X9D8U+gdDUCpG+H/8=",
"optional": true
},
"n64": {
"version": "0.0.11",
"resolved": "https://registry.npmjs.org/n64/-/n64-0.0.11.tgz",
"integrity": "sha1-NFG8by8g/okyxkfodoXFi+SjSJo="
},
"socket.io": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/socket.io/-/socket.io-2.0.1.tgz",
@ -256,16 +284,6 @@
}
}
},
"bcoin-native": {
"version": "0.0.23",
"resolved": "https://registry.npmjs.org/bcoin-native/-/bcoin-native-0.0.23.tgz",
"integrity": "sha512-bk2XK9EtOcTiqS4cgJ5dy77R2bVJC65dTvLuhH+SxLemjERC3jbf8jadYvOYfZx/x8TF6fuxZzWruhc0OF3Bnw==",
"optional": true,
"requires": {
"bindings": "1.2.1",
"nan": "2.6.2"
}
},
"bcrypt-pbkdf": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/bcrypt-pbkdf/-/bcrypt-pbkdf-1.0.1.tgz",
@ -384,16 +402,11 @@
"bitcore-p2p": {
"version": "github:bitpay/bitcore-p2p#5de3ca9eabc1ad7dbeeb882e5b3f85c5f6a4ed9d",
"requires": {
"bcoin": "github:bcoin-org/bcoin#ffec8ff2d7e05591d113004ed1aca6e0c4fd1d20",
"bcoin": "github:bcoin-org/bcoin#886008a1822ce1da7fa8395ee7db4bcc1750a28a",
"bitcore-lib": "0.14.0",
"bloom-filter": "0.2.0",
"buffers": "github:bitpay/node-buffers#04f4c4264e0d105db2b99b786843ed64f23230d8",
"socks5-client": "0.3.6"
},
"dependencies": {
"buffers": {
"version": "github:bitpay/node-buffers#04f4c4264e0d105db2b99b786843ed64f23230d8"
}
}
},
"bl": {
@ -503,6 +516,9 @@
"integrity": "sha1-JuYe0UIvtw3ULm42cp7VHYVf6Nk=",
"optional": true
},
"buffers": {
"version": "github:bitpay/node-buffers#04f4c4264e0d105db2b99b786843ed64f23230d8"
},
"bufferutil": {
"version": "1.2.1",
"resolved": "https://registry.npmjs.org/bufferutil/-/bufferutil-1.2.1.tgz",
@ -2643,11 +2659,6 @@
}
}
},
"n64": {
"version": "0.0.12",
"resolved": "https://registry.npmjs.org/n64/-/n64-0.0.12.tgz",
"integrity": "sha512-Apl4Wy7GeLySDv2974ajM80DTTuD/RHk59ORtkR/jsbt9hmPcKJYzUkjFIGOlUMA13nvx7sY2fet+Lb6KYQdWA=="
},
"nan": {
"version": "2.6.2",
"resolved": "https://registry.npmjs.org/nan/-/nan-2.6.2.tgz",

View File

@ -50,7 +50,7 @@
],
"dependencies": {
"async": "^2.5.0",
"bcoin": "1.0.0-beta.12",
"bcoin": "bcoin-org/bcoin#886008a1822ce1da7fa8395ee7db4bcc1750a28a",
"bitcoind-rpc": "^0.6.0",
"bitcore-lib": "^0.14",
"body-parser": "^1.13.3",