remove tx-pool coin functions.
This commit is contained in:
parent
7d17dd855f
commit
7fbfc1e248
@ -217,65 +217,19 @@ TXPool.prototype.getCoin = function getCoin(hash, index) {
|
|||||||
return this._unspent[hash + '/' + index];
|
return this._unspent[hash + '/' + index];
|
||||||
};
|
};
|
||||||
|
|
||||||
TXPool.prototype.addCoin = function addCoin(coin, noWrite) {
|
TXPool.prototype.getOutput = function getOutput(hash, index) {
|
||||||
var id = coin.hash + '/' + coin.index;
|
var id = hash + '/' + index;
|
||||||
|
var tx;
|
||||||
|
|
||||||
// Do not add TX two times
|
if (this._unspent[id])
|
||||||
if (this._unspent[id]) {
|
return this._unspent[id];
|
||||||
// Transaction was confirmed, update it in storage
|
|
||||||
if (coin.height !== -1 && this._unspent[id].height === -1) {
|
|
||||||
this._unspent[key].height = coin.height;
|
|
||||||
this._lastHeight = Math.max(tx.height, this._lastHeight);
|
|
||||||
this.emit('update', this._lastTs, this._lastHeight, tx);
|
|
||||||
this.emit('confirmed', tx);
|
|
||||||
// this._storeCoin(coin, noWrite);
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Problem here: could in some cases add
|
tx = this._all[hash];
|
||||||
// an unspent that was already redeemed.
|
|
||||||
if (this._all[coin.hash])
|
if (!tx)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
this._unspent[id] = coin;
|
return bcoin.coin(tx, index);
|
||||||
this._addOutput(coin);
|
|
||||||
this._lastHeight = Math.max(coin.height, this._lastHeight);
|
|
||||||
this.emit('update', this._lastTs, this._lastHeight);
|
|
||||||
// Weird workaround to get addresses to update
|
|
||||||
if (coin.height !== -1)
|
|
||||||
this.emit('confirmed', coin);
|
|
||||||
// this._storeCoin(coin, noWrite);
|
|
||||||
};
|
|
||||||
|
|
||||||
TXPool.prototype._storeCoin = function _storeCoin(id, coin, noWrite) {
|
|
||||||
var self = this;
|
|
||||||
|
|
||||||
if (!this._storage || noWrite)
|
|
||||||
return;
|
|
||||||
|
|
||||||
this._storage.put(this._prefix + id, coin.toJSON(), function(err) {
|
|
||||||
if (err)
|
|
||||||
self.emit('error', err);
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
TXPool.prototype._removeCoin = function _removeCoin(id, noWrite) {
|
|
||||||
var self = this;
|
|
||||||
var key;
|
|
||||||
|
|
||||||
if (this._unspent[id]) {
|
|
||||||
this._removeOutput(this._unspent[id]);
|
|
||||||
delete this._unspent[id];
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!this._storage || noWrite)
|
|
||||||
return;
|
|
||||||
|
|
||||||
this._storage.del(this._prefix + id, function(err) {
|
|
||||||
if (err)
|
|
||||||
self.emit('error', err);
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
TXPool.prototype._storeTX = function _storeTX(hash, tx, noWrite) {
|
TXPool.prototype._storeTX = function _storeTX(hash, tx, noWrite) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user