Small improvements on the mining page UX

- INDEXING_BLOCKS_AMOUNT = 0 disable indexing, INDEXING_BLOCKS_AMOUNT = -1 indexes everything
- Show only available timespan in the mining page according to available datas
- Change default INDEXING_BLOCKS_AMOUNT to 1100

Don't use unfiltered mysql user input

Enable http cache header for mining pools (1 min)
This commit is contained in:
nymkappa
2022-01-25 18:33:46 +09:00
parent d66bc57165
commit 6ebbc5667d
20 changed files with 183 additions and 121 deletions

View File

@@ -121,8 +121,11 @@ export class ApiService {
return this.httpClient.post<any>(this.apiBaseUrl + this.apiBasePath + '/api/tx', hexPayload, { responseType: 'text' as 'json'});
}
listPools$(interval: string) : Observable<PoolsStats> {
const params = new HttpParams().set('interval', interval);
return this.httpClient.get<PoolsStats>(this.apiBaseUrl + this.apiBasePath + '/api/v1/pools', {params});
listPools$(interval: string | null) : Observable<PoolsStats> {
let params = {};
if (interval) {
params = new HttpParams().set('interval', interval);
}
return this.httpClient.get<PoolsStats>(this.apiBaseUrl + this.apiBasePath + '/api/v1/mining/pools', {params});
}
}

View File

@@ -17,6 +17,7 @@ export interface MiningStats {
totalEmptyBlockRatio: string;
pools: SinglePoolStats[];
miningUnits: MiningUnits;
availableTimespanDay: number;
}
@Injectable({
@@ -80,6 +81,10 @@ export class MiningService {
};
});
const availableTimespanDay = (
(new Date().getTime() / 1000) - (stats.oldestIndexedBlockTimestamp / 1000)
) / 3600 / 24;
return {
lastEstimatedHashrate: (stats.lastEstimatedHashrate / hashrateDivider).toFixed(2),
blockCount: stats.blockCount,
@@ -87,6 +92,7 @@ export class MiningService {
totalEmptyBlockRatio: totalEmptyBlockRatio,
pools: poolsStats,
miningUnits: miningUnits,
availableTimespanDay: availableTimespanDay,
};
}
}

View File

@@ -7,7 +7,7 @@ import { Router, ActivatedRoute } from '@angular/router';
export class StorageService {
constructor(private router: Router, private route: ActivatedRoute) {
this.setDefaultValueIfNeeded('graphWindowPreference', '2h');
this.setDefaultValueIfNeeded('poolsWindowPreference', '1d');
this.setDefaultValueIfNeeded('poolsWindowPreference', '1w');
}
setDefaultValueIfNeeded(key: string, defaultValue: string) {