Added first seen on mempool transactions.

This commit is contained in:
softsimon
2020-02-28 01:09:07 +07:00
parent 23a61a37fd
commit 4879036216
17 changed files with 100 additions and 34 deletions

View File

@@ -52,12 +52,25 @@ class Mempool {
return this.vBytesPerSecond;
}
public getFirstSeenForTransactions(txIds: string[]): number[] {
const txTimes: number[] = [];
txIds.forEach((txId: string) => {
if (this.mempoolCache[txId]) {
txTimes.push(this.mempoolCache[txId].firstSeen);
} else {
txTimes.push(0);
}
});
return txTimes;
}
public async getTransactionExtended(txId: string): Promise<TransactionExtended | false> {
try {
const transaction: Transaction = await bitcoinApi.getRawTransaction(txId);
return Object.assign({
vsize: transaction.weight / 4,
feePerVsize: transaction.fee / (transaction.weight / 4),
firstSeen: Math.round((new Date().getTime() / 1000)),
}, transaction);
} catch (e) {
console.log(txId + ' not found');