Load more mempool transactions
This commit is contained in:
		
							parent
							
								
									cff2022baf
								
							
						
					
					
						commit
						5ef592f53e
					
				| @ -207,7 +207,7 @@ export class AddressComponent implements OnInit, OnDestroy { | |||||||
|     } |     } | ||||||
|     this.isLoadingTransactions = true; |     this.isLoadingTransactions = true; | ||||||
|     this.retryLoadMore = false; |     this.retryLoadMore = false; | ||||||
|     this.electrsApiService.getAddressTransactionsFromHash$(this.address.address, this.lastTransactionTxId) |     this.electrsApiService.getAddressTransactions$(this.address.address, this.lastTransactionTxId) | ||||||
|       .subscribe((transactions: Transaction[]) => { |       .subscribe((transactions: Transaction[]) => { | ||||||
|         this.lastTransactionTxId = transactions[transactions.length - 1].txid; |         this.lastTransactionTxId = transactions[transactions.length - 1].txid; | ||||||
|         this.loadedConfirmedTxCount += transactions.length; |         this.loadedConfirmedTxCount += transactions.length; | ||||||
| @ -217,6 +217,10 @@ export class AddressComponent implements OnInit, OnDestroy { | |||||||
|       (error) => { |       (error) => { | ||||||
|         this.isLoadingTransactions = false; |         this.isLoadingTransactions = false; | ||||||
|         this.retryLoadMore = true; |         this.retryLoadMore = true; | ||||||
|  |         // In the unlikely event of the txid wasn't found in the mempool anymore and we must reload the page.
 | ||||||
|  |         if (error.status === 422) { | ||||||
|  |           window.location.reload(); | ||||||
|  |         } | ||||||
|       }); |       }); | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -1,5 +1,5 @@ | |||||||
| import { Injectable } from '@angular/core'; | import { Injectable } from '@angular/core'; | ||||||
| import { HttpClient } from '@angular/common/http'; | import { HttpClient, HttpParams } from '@angular/common/http'; | ||||||
| import { Observable } from 'rxjs'; | import { Observable } from 'rxjs'; | ||||||
| import { Transaction, Address, Outspend, Recent, Asset } from '../interfaces/electrs.interface'; | import { Transaction, Address, Outspend, Recent, Asset } from '../interfaces/electrs.interface'; | ||||||
| import { StateService } from './state.service'; | import { StateService } from './state.service'; | ||||||
| @ -65,12 +65,12 @@ export class ElectrsApiService { | |||||||
|     return this.httpClient.get<Address>(this.apiBaseUrl + this.apiBasePath + '/api/address/' + address); |     return this.httpClient.get<Address>(this.apiBaseUrl + this.apiBasePath + '/api/address/' + address); | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|   getAddressTransactions$(address: string): Observable<Transaction[]> { |   getAddressTransactions$(address: string,  txid?: string): Observable<Transaction[]> { | ||||||
|     return this.httpClient.get<Transaction[]>(this.apiBaseUrl + this.apiBasePath + '/api/address/' + address + '/txs'); |     let params = new HttpParams(); | ||||||
|  |     if (txid) { | ||||||
|  |       params = params.append('after_txid', txid); | ||||||
|     } |     } | ||||||
| 
 |     return this.httpClient.get<Transaction[]>(this.apiBaseUrl + this.apiBasePath + '/api/address/' + address + '/txs', { params }); | ||||||
|   getAddressTransactionsFromHash$(address: string, txid: string): Observable<Transaction[]> { |  | ||||||
|     return this.httpClient.get<Transaction[]>(this.apiBaseUrl + this.apiBasePath + '/api/address/' + address + '/txs/chain/' + txid); |  | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|   getAsset$(assetId: string): Observable<Asset> { |   getAsset$(assetId: string): Observable<Asset> { | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user