mempool: do not hold chain lock while getting viewpoint.
This commit is contained in:
parent
9fd7153100
commit
9490d29390
@ -1502,7 +1502,8 @@ Mempool.prototype.isDoubleSpend = function isDoubleSpend(tx) {
|
|||||||
* @returns {Promise} - Returns {@link CoinView}.
|
* @returns {Promise} - Returns {@link CoinView}.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
Mempool.prototype._getCoinView = co(function* getCoinView(tx) {
|
Mempool.prototype.getCoinView = co(function* getCoinView(tx) {
|
||||||
|
var state = this.chain.state;
|
||||||
var view = new CoinView();
|
var view = new CoinView();
|
||||||
var prevout = tx.getPrevout();
|
var prevout = tx.getPrevout();
|
||||||
var i, entry, hash, coins;
|
var i, entry, hash, coins;
|
||||||
@ -1528,6 +1529,9 @@ Mempool.prototype._getCoinView = co(function* getCoinView(tx) {
|
|||||||
view.add(coins);
|
view.add(coins);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (state !== this.chain.state)
|
||||||
|
throw new Error('Chain state changed while getting coins.');
|
||||||
|
|
||||||
return view;
|
return view;
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -1538,8 +1542,9 @@ Mempool.prototype._getCoinView = co(function* getCoinView(tx) {
|
|||||||
* @returns {Promise} - Returns {@link CoinView}.
|
* @returns {Promise} - Returns {@link CoinView}.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
Mempool.prototype.getCoinView = co(function* getCoinView(tx) {
|
Mempool.prototype._getCoinView = co(function* getCoinView(tx) {
|
||||||
var view = yield this.chain.getCoinView(tx);
|
var state = this.chain.state;
|
||||||
|
var view = yield this.chain.db.getCoinView(tx);
|
||||||
var items = view.toArray();
|
var items = view.toArray();
|
||||||
var i, coins, entry;
|
var i, coins, entry;
|
||||||
|
|
||||||
@ -1557,6 +1562,9 @@ Mempool.prototype.getCoinView = co(function* getCoinView(tx) {
|
|||||||
view.addTX(entry.tx, -1);
|
view.addTX(entry.tx, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (state !== this.chain.state)
|
||||||
|
throw new Error('Chain state changed while getting coins.');
|
||||||
|
|
||||||
return view;
|
return view;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user