mirror of
https://github.com/mempool/mempool.git
synced 2025-01-19 05:34:03 +01:00
Additional fixes for address transaction fetching.
This commit is contained in:
parent
3d3cec2582
commit
ef862e2442
@ -48,6 +48,7 @@ export class AddressComponent implements OnInit, OnDestroy {
|
|||||||
.subscribe((params: ParamMap) => {
|
.subscribe((params: ParamMap) => {
|
||||||
this.error = undefined;
|
this.error = undefined;
|
||||||
this.isLoadingAddress = true;
|
this.isLoadingAddress = true;
|
||||||
|
this.loadedConfirmedTxCount = 0;
|
||||||
this.isLoadingTransactions = true;
|
this.isLoadingTransactions = true;
|
||||||
this.transactions = null;
|
this.transactions = null;
|
||||||
document.body.scrollTo(0, 0);
|
document.body.scrollTo(0, 0);
|
||||||
@ -115,9 +116,9 @@ export class AddressComponent implements OnInit, OnDestroy {
|
|||||||
return this.electrsApiService.getAddressTransactions$(address.address);
|
return this.electrsApiService.getAddressTransactions$(address.address);
|
||||||
}),
|
}),
|
||||||
switchMap((transactions) => {
|
switchMap((transactions) => {
|
||||||
this.lastTransactionTxId = transactions[transactions.length - 1].txid;
|
|
||||||
this.tempTransactions = transactions;
|
this.tempTransactions = transactions;
|
||||||
this.loadedConfirmedTxCount = transactions.filter((tx) => tx.status.confirmed).length;
|
this.lastTransactionTxId = transactions[transactions.length - 1].txid;
|
||||||
|
this.loadedConfirmedTxCount += transactions.filter((tx) => tx.status.confirmed).length;
|
||||||
|
|
||||||
const fetchTxs: string[] = [];
|
const fetchTxs: string[] = [];
|
||||||
this.timeTxIndexes = [];
|
this.timeTxIndexes = [];
|
||||||
@ -151,6 +152,16 @@ export class AddressComponent implements OnInit, OnDestroy {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
loadMore() {
|
||||||
|
this.isLoadingTransactions = true;
|
||||||
|
this.electrsApiService.getAddressTransactionsFromHash$(this.address.address, this.lastTransactionTxId)
|
||||||
|
.subscribe((transactions: Transaction[]) => {
|
||||||
|
this.loadedConfirmedTxCount += transactions.length;
|
||||||
|
this.transactions = this.transactions.concat(transactions);
|
||||||
|
this.isLoadingTransactions = false;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
updateChainStats() {
|
updateChainStats() {
|
||||||
this.receieved = this.address.chain_stats.funded_txo_sum + this.address.mempool_stats.funded_txo_sum;
|
this.receieved = this.address.chain_stats.funded_txo_sum + this.address.mempool_stats.funded_txo_sum;
|
||||||
this.sent = this.address.chain_stats.spent_txo_sum + this.address.mempool_stats.spent_txo_sum;
|
this.sent = this.address.chain_stats.spent_txo_sum + this.address.mempool_stats.spent_txo_sum;
|
||||||
@ -158,42 +169,6 @@ export class AddressComponent implements OnInit, OnDestroy {
|
|||||||
this.totalConfirmedTxCount = this.address.chain_stats.tx_count;
|
this.totalConfirmedTxCount = this.address.chain_stats.tx_count;
|
||||||
}
|
}
|
||||||
|
|
||||||
loadMore() {
|
|
||||||
this.isLoadingTransactions = true;
|
|
||||||
this.electrsApiService.getAddressTransactionsFromHash$(this.address.address, this.lastTransactionTxId)
|
|
||||||
.pipe(
|
|
||||||
switchMap((transactions) => {
|
|
||||||
this.tempTransactions = transactions;
|
|
||||||
this.lastTransactionTxId = transactions[transactions.length - 1].txid;
|
|
||||||
this.loadedConfirmedTxCount += transactions.filter((tx) => tx.status.confirmed).length;
|
|
||||||
|
|
||||||
const fetchTxs: string[] = [];
|
|
||||||
this.timeTxIndexes = [];
|
|
||||||
transactions.forEach((tx, index) => {
|
|
||||||
if (!tx.status.confirmed) {
|
|
||||||
fetchTxs.push(tx.txid);
|
|
||||||
this.timeTxIndexes.push(index);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
if (!fetchTxs.length) {
|
|
||||||
return of([]);
|
|
||||||
}
|
|
||||||
return this.apiService.getTransactionTimes$(fetchTxs);
|
|
||||||
})
|
|
||||||
)
|
|
||||||
.subscribe((times: number[]) => {
|
|
||||||
times.forEach((time, index) => {
|
|
||||||
this.tempTransactions[this.timeTxIndexes[index]].firstSeen = time;
|
|
||||||
});
|
|
||||||
this.tempTransactions.sort((a, b) => {
|
|
||||||
return b.status.block_time - a.status.block_time || b.firstSeen - a.firstSeen;
|
|
||||||
});
|
|
||||||
|
|
||||||
this.transactions = this.transactions.concat(this.tempTransactions);
|
|
||||||
this.isLoadingTransactions = false;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
ngOnDestroy() {
|
ngOnDestroy() {
|
||||||
this.websocketService.startTrackAddress('stop');
|
this.websocketService.startTrackAddress('stop');
|
||||||
}
|
}
|
||||||
|
@ -2,5 +2,5 @@
|
|||||||
<span>{{ conversions.USD * (satoshis / 100000000) | currency:'USD':'symbol':'1.2-2' }}</span>
|
<span>{{ conversions.USD * (satoshis / 100000000) | currency:'USD':'symbol':'1.2-2' }}</span>
|
||||||
</ng-container>
|
</ng-container>
|
||||||
<ng-template #viewFiatVin>
|
<ng-template #viewFiatVin>
|
||||||
{{ satoshis / 100000000 }} BTC
|
{{ satoshis / 100000000 | number : '1.8-8' }} BTC
|
||||||
</ng-template>
|
</ng-template>
|
||||||
|
Loading…
Reference in New Issue
Block a user