mirror of
https://github.com/Xahau/xahau.js.git
synced 2025-12-06 17:27:59 +00:00
Update tests
This commit is contained in:
@@ -199,7 +199,7 @@ Request.prototype.ledgerSelect = function(ledger) {
|
||||
switch (ledger) {
|
||||
case 'current':
|
||||
case 'closed':
|
||||
case 'verified':
|
||||
case 'validated':
|
||||
this.message.ledger_index = ledger;
|
||||
break;
|
||||
|
||||
@@ -327,7 +327,7 @@ Request.prototype.books = function(books, snapshot) {
|
||||
return this;
|
||||
};
|
||||
|
||||
Request.prototype.addBook = function (book, snapshot) {
|
||||
Request.prototype.addBook = function(book, snapshot) {
|
||||
if (!Array.isArray(this.message.books)) {
|
||||
this.message.books = [ ];
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
*/
|
||||
|
||||
var LRU = require('lru-cache');
|
||||
var Transaction = require('./transaction').Transaction;
|
||||
|
||||
function TransactionQueue() {
|
||||
this._queue = [ ];
|
||||
@@ -19,6 +20,15 @@ TransactionQueue.prototype.addReceivedSequence = function(sequence) {
|
||||
this._sequenceCache.set(String(sequence), true);
|
||||
};
|
||||
|
||||
/**
|
||||
* Check that sequence number has been consumed by a validated
|
||||
* transaction
|
||||
*/
|
||||
|
||||
TransactionQueue.prototype.hasSequence = function(sequence) {
|
||||
return this._sequenceCache.has(String(sequence));
|
||||
};
|
||||
|
||||
/**
|
||||
* Store received (validated) ID transaction
|
||||
*/
|
||||
@@ -35,22 +45,13 @@ TransactionQueue.prototype.getReceived = function(id) {
|
||||
return this._idCache.get(id);
|
||||
};
|
||||
|
||||
/**
|
||||
* Check that sequence number has been consumed by a validated
|
||||
* transaction
|
||||
*/
|
||||
|
||||
TransactionQueue.prototype.hasSequence = function(sequence) {
|
||||
return this._sequenceCache.has(String(sequence));
|
||||
};
|
||||
|
||||
/**
|
||||
* Get a submitted transaction by ID. Transactions
|
||||
* may have multiple associated IDs.
|
||||
*/
|
||||
|
||||
TransactionQueue.prototype.getSubmission = function(id) {
|
||||
var result = false;
|
||||
var result = void(0);
|
||||
|
||||
for (var i=0, tx; (tx=this._queue[i]); i++) {
|
||||
if (~tx.submittedIDs.indexOf(id)) {
|
||||
@@ -70,6 +71,14 @@ TransactionQueue.prototype.remove = function(tx) {
|
||||
// ND: We are just removing the Transaction by identity
|
||||
var i = this._queue.length;
|
||||
|
||||
if (typeof tx === 'string') {
|
||||
tx = this.getSubmission(tx);
|
||||
}
|
||||
|
||||
if (!(tx instanceof Transaction)) {
|
||||
return;
|
||||
}
|
||||
|
||||
while (i--) {
|
||||
if (this._queue[i] === tx) {
|
||||
this._queue.splice(i, 1);
|
||||
|
||||
Reference in New Issue
Block a user