Use block count instead of oldest block for timespan selection
This commit is contained in:
@@ -125,10 +125,10 @@ export class ApiService {
|
||||
return this.httpClient.post<any>(this.apiBaseUrl + this.apiBasePath + '/api/tx', hexPayload, { responseType: 'text' as 'json'});
|
||||
}
|
||||
|
||||
listPools$(interval: string | undefined) : Observable<PoolsStats> {
|
||||
return this.httpClient.get<PoolsStats>(
|
||||
listPools$(interval: string | undefined) : Observable<any> {
|
||||
return this.httpClient.get<any>(
|
||||
this.apiBaseUrl + this.apiBasePath + `/api/v1/mining/pools` +
|
||||
(interval !== undefined ? `/${interval}` : '')
|
||||
(interval !== undefined ? `/${interval}` : ''), { observe: 'response' }
|
||||
);
|
||||
}
|
||||
|
||||
@@ -157,28 +157,28 @@ export class ApiService {
|
||||
getHistoricalHashrate$(interval: string | undefined): Observable<any> {
|
||||
return this.httpClient.get<any[]>(
|
||||
this.apiBaseUrl + this.apiBasePath + `/api/v1/mining/hashrate` +
|
||||
(interval !== undefined ? `/${interval}` : '')
|
||||
(interval !== undefined ? `/${interval}` : ''), { observe: 'response' }
|
||||
);
|
||||
}
|
||||
|
||||
getHistoricalPoolsHashrate$(interval: string | undefined): Observable<any> {
|
||||
return this.httpClient.get<any[]>(
|
||||
this.apiBaseUrl + this.apiBasePath + `/api/v1/mining/hashrate/pools` +
|
||||
(interval !== undefined ? `/${interval}` : '')
|
||||
(interval !== undefined ? `/${interval}` : ''), { observe: 'response' }
|
||||
);
|
||||
}
|
||||
|
||||
getHistoricalBlockFees$(interval: string | undefined) : Observable<any> {
|
||||
return this.httpClient.get<any[]>(
|
||||
this.apiBaseUrl + this.apiBasePath + `/api/v1/mining/blocks/fees` +
|
||||
(interval !== undefined ? `/${interval}` : '')
|
||||
(interval !== undefined ? `/${interval}` : ''), { observe: 'response' }
|
||||
);
|
||||
}
|
||||
|
||||
getHistoricalBlockRewards$(interval: string | undefined) : Observable<any> {
|
||||
return this.httpClient.get<any[]>(
|
||||
this.apiBaseUrl + this.apiBasePath + `/api/v1/mining/blocks/rewards` +
|
||||
(interval !== undefined ? `/${interval}` : '')
|
||||
(interval !== undefined ? `/${interval}` : ''), { observe: 'response' }
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ export interface MiningStats {
|
||||
totalEmptyBlockRatio: string;
|
||||
pools: SinglePoolStats[];
|
||||
miningUnits: MiningUnits;
|
||||
availableTimespanDay: number;
|
||||
totalBlockCount: number;
|
||||
}
|
||||
|
||||
@Injectable({
|
||||
@@ -37,7 +37,7 @@ export class MiningService {
|
||||
*/
|
||||
public getMiningStats(interval: string): Observable<MiningStats> {
|
||||
return this.apiService.listPools$(interval).pipe(
|
||||
map(pools => this.generateMiningStats(pools))
|
||||
map(response => this.generateMiningStats(response))
|
||||
);
|
||||
}
|
||||
|
||||
@@ -82,7 +82,8 @@ export class MiningService {
|
||||
return preference;
|
||||
}
|
||||
|
||||
private generateMiningStats(stats: PoolsStats): MiningStats {
|
||||
private generateMiningStats(response): MiningStats {
|
||||
const stats: PoolsStats = response.body;
|
||||
const miningUnits = this.getMiningUnits();
|
||||
const hashrateDivider = miningUnits.hashrateDivider;
|
||||
|
||||
@@ -100,10 +101,6 @@ export class MiningService {
|
||||
};
|
||||
});
|
||||
|
||||
const availableTimespanDay = (
|
||||
(new Date().getTime() / 1000) - (stats.oldestIndexedBlockTimestamp)
|
||||
) / 3600 / 24;
|
||||
|
||||
return {
|
||||
lastEstimatedHashrate: (stats.lastEstimatedHashrate / hashrateDivider).toFixed(2),
|
||||
blockCount: stats.blockCount,
|
||||
@@ -111,7 +108,7 @@ export class MiningService {
|
||||
totalEmptyBlockRatio: totalEmptyBlockRatio,
|
||||
pools: poolsStats,
|
||||
miningUnits: miningUnits,
|
||||
availableTimespanDay: availableTimespanDay,
|
||||
totalBlockCount: parseInt(response.headers.get('x-total-count'), 10),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user