This commit is contained in:
wltsmrz
2013-12-17 12:56:53 -08:00
parent 667919cea1
commit 94c57bc0d8
3 changed files with 17 additions and 12 deletions

View File

@@ -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);
}
};

View File

@@ -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);

View File

@@ -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;