mirror of
https://github.com/Xahau/xahau.js.git
synced 2026-08-23 16:40:52 +00:00
Cleanup
This commit is contained in:
@@ -217,7 +217,7 @@ Transaction.prototype.signingHash = function() {
|
||||
};
|
||||
|
||||
Transaction.prototype.addSubmittedTxnID = function(hash) {
|
||||
if (-1 == this.submittedTxnIDs.indexOf(hash)) {
|
||||
if (this.submittedTxnIDs.indexOf(hash) === -1) {
|
||||
this.submittedTxnIDs.push(hash);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -357,6 +357,7 @@ TransactionManager.prototype._request = function(tx) {
|
||||
if (tx.finalized) return;
|
||||
|
||||
tx.emit('timeout');
|
||||
|
||||
if (remote._connected) {
|
||||
remote._trace('transactionmanager: timeout: %s', tx.tx_json);
|
||||
self._resubmit(3, tx);
|
||||
|
||||
@@ -7,32 +7,36 @@ TransactionQueue.prototype.length = function() {
|
||||
};
|
||||
|
||||
TransactionQueue.prototype.getBySubmissions = function(hash) {
|
||||
var result = false;
|
||||
|
||||
top:
|
||||
for (var i=0, tx; tx=this._queue[i]; i++) {
|
||||
for (var j=0, id; id=tx.submittedTxnIDs[j]; j++) {
|
||||
if (hash === id) {
|
||||
return tx;
|
||||
result = tx;
|
||||
break top;
|
||||
};
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
||||
return result;
|
||||
};
|
||||
|
||||
// ND: We are just removing the Transaction by identity
|
||||
TransactionQueue.prototype.remove = function(removedTx) {
|
||||
top:
|
||||
for (var i = this._queue.length - 1; i >= 0; i--) {
|
||||
if (this._queue[i] === removedTx) {
|
||||
this._queue.splice(i, 1);
|
||||
break;
|
||||
break top;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
TransactionQueue.prototype.forEach = function() {
|
||||
Array.prototype.forEach.apply(this._queue, arguments);
|
||||
};
|
||||
[ 'forEach', 'push', 'shift', 'unshift' ].forEach(function(fn) {
|
||||
TransactionQueue.prototype[fn] = function() {
|
||||
Array.prototype[fn].apply(this._queue, arguments);
|
||||
};
|
||||
});
|
||||
|
||||
TransactionQueue.prototype.push = function() {
|
||||
Array.prototype.push.apply(this._queue, arguments);
|
||||
};
|
||||
|
||||
exports.TransactionQueue = TransactionQueue;
|
||||
exports.TransactionQueue = TransactionQueue;
|
||||
|
||||
Reference in New Issue
Block a user