Add check for transaction in current transactions list.
This commit is contained in:
parent
9235c969fa
commit
a003bd7124
@ -108,9 +108,14 @@ export class TransactionService {
|
||||
}
|
||||
|
||||
addTransaction(transaction, cacheSize: number): void {
|
||||
const savedIndex = this.transactions.findIndex(tx => tx.tx.txHash === transaction.tx.txHash);
|
||||
if (savedIndex === 0) { return; }
|
||||
if (savedIndex > 0) {
|
||||
this.transactions.splice(savedIndex, 1);
|
||||
}
|
||||
this.transactions.unshift(transaction);
|
||||
if (this.transactions.length > cacheSize) {
|
||||
this.transactions.length = cacheSize;
|
||||
this.transactions.length = Math.min(this.transactions.length, cacheSize);
|
||||
}
|
||||
this.transactionList.next(this.transactions);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user