Move reward stats to component - Add /api/v1/mining/reward-stats/{blockCount}

This commit is contained in:
nymkappa
2022-03-22 12:34:29 +09:00
parent 5c629dfe98
commit 2644f2fb07
15 changed files with 202 additions and 110 deletions

View File

@@ -0,0 +1,29 @@
import { ChangeDetectionStrategy, Component, OnInit } from '@angular/core';
import { Observable } from 'rxjs';
import { map } from 'rxjs/operators';
import { ApiService } from 'src/app/services/api.service';
@Component({
selector: 'app-reward-stats',
templateUrl: './reward-stats.component.html',
styleUrls: ['./reward-stats.component.scss'],
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class RewardStatsComponent implements OnInit {
public $rewardStats: Observable<any>;
constructor(private apiService: ApiService) { }
ngOnInit(): void {
this.$rewardStats = this.apiService.getRewardStats$()
.pipe(
map((res) => {
return {
totalReward: res.totalReward,
rewardPerTx: res.totalReward / res.totalTx,
feePerTx: res.totalFee / res.totalTx,
};
})
);
}
}