Bufix: Miner started reloading when switching transaction page

This commit is contained in:
softsimon 2020-07-20 10:29:38 +07:00
parent eac605f181
commit 5e16c592cb
No known key found for this signature in database
GPG Key ID: 488D7DCFB5A430D7
2 changed files with 9 additions and 1 deletions

View File

@ -69,7 +69,7 @@
</ng-template> </ng-template>
<tr> <tr>
<td>Miner</td> <td>Miner</td>
<td><app-miner [coinbaseTransaction]="block.coinbaseTx || (transactions && transactions[0])"></app-miner></td> <td><app-miner [coinbaseTransaction]="coinbaseTx"></app-miner></td>
</tr> </tr>
</tbody> </tbody>
</table> </table>

View File

@ -28,6 +28,7 @@ export class BlockComponent implements OnInit, OnDestroy {
subscription: Subscription; subscription: Subscription;
fees: number; fees: number;
paginationMaxSize: number; paginationMaxSize: number;
coinbaseTx: Transaction;
page = 1; page = 1;
itemsPerPage = env.ELCTRS_ITEMS_PER_PAGE; itemsPerPage = env.ELCTRS_ITEMS_PER_PAGE;
@ -50,6 +51,7 @@ export class BlockComponent implements OnInit, OnDestroy {
const blockHash: string = params.get('id') || ''; const blockHash: string = params.get('id') || '';
this.block = undefined; this.block = undefined;
this.page = 1; this.page = 1;
this.coinbaseTx = undefined;
this.error = undefined; this.error = undefined;
this.fees = undefined; this.fees = undefined;
this.stateService.markBlock$.next({}); this.stateService.markBlock$.next({});
@ -92,6 +94,9 @@ export class BlockComponent implements OnInit, OnDestroy {
this.blockHeight = block.height; this.blockHeight = block.height;
this.seoService.setTitle('Block: #' + block.height + ': ' + block.id, true); this.seoService.setTitle('Block: #' + block.height + ': ' + block.id, true);
this.isLoadingBlock = false; this.isLoadingBlock = false;
if (block.coinbaseTx) {
this.coinbaseTx = block.coinbaseTx;
}
this.setBlockSubsidy(); this.setBlockSubsidy();
if (block.reward) { if (block.reward) {
this.fees = block.reward / 100000000 - this.blockSubsidy; this.fees = block.reward / 100000000 - this.blockSubsidy;
@ -113,6 +118,9 @@ export class BlockComponent implements OnInit, OnDestroy {
if (this.fees === undefined && transactions[0]) { if (this.fees === undefined && transactions[0]) {
this.fees = transactions[0].vout.reduce((acc: number, curr: Vout) => acc + curr.value, 0) / 100000000 - this.blockSubsidy; this.fees = transactions[0].vout.reduce((acc: number, curr: Vout) => acc + curr.value, 0) / 100000000 - this.blockSubsidy;
} }
if (!this.coinbaseTx && transactions[0]) {
this.coinbaseTx = transactions[0];
}
this.transactions = transactions; this.transactions = transactions;
this.isLoadingTransactions = false; this.isLoadingTransactions = false;
}, },