Changes
This commit is contained in:
parent
79f5223683
commit
d410ca2ca5
@ -192,7 +192,7 @@ export class BlockchainBlockController {
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
* /epic_explorer/v1/blockchain_block/totaldiffnblock:
|
||||
* /epic_explorer/v1/blockchain_block/totaldiff:
|
||||
* get:
|
||||
* tags:
|
||||
* - name: BLOCKCHAIN_BLOCK | BLOCKCHAIN_BLOCK CONTROLLER
|
||||
@ -217,13 +217,48 @@ export class BlockchainBlockController {
|
||||
* type: string
|
||||
* responses:
|
||||
* 200:
|
||||
* description: Total Difficulty and No. of blocks fetched successfully
|
||||
* description: Total Difficulty fetched successfully
|
||||
*/
|
||||
this.router.get(
|
||||
`${this.path}/totaldiffnblock`,
|
||||
`${this.path}/totaldiff`,
|
||||
validationMiddleware(TotalDifficultyNBlockDto, true),
|
||||
this.TotalDifficultyNBlock,
|
||||
);
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
* /epic_explorer/v1/blockchain_block/blockcount:
|
||||
* get:
|
||||
* tags:
|
||||
* - name: BLOCKCHAIN_BLOCK | BLOCKCHAIN_BLOCK CONTROLLER
|
||||
* description: To get Total Difficulty and Number of Blocks
|
||||
* summary: To get Total Difficulty and Number of Blocks
|
||||
* consumes:
|
||||
* - application/json
|
||||
* produces:
|
||||
* - application/json
|
||||
* parameters:
|
||||
* - name: FromDate
|
||||
* description: Enter the From date
|
||||
* in: query
|
||||
* type: string
|
||||
* - name: ToDate
|
||||
* description: Enter the To date
|
||||
* in: query
|
||||
* type: string
|
||||
* - name: Interval
|
||||
* description: Try to give Intevals such as 1 week/ 15 days/ 30 days/ 60 days/ 3 months
|
||||
* in: query
|
||||
* type: string
|
||||
* responses:
|
||||
* 200:
|
||||
* description: Total Difficulty fetched successfully
|
||||
*/
|
||||
this.router.get(
|
||||
`${this.path}/blockcount`,
|
||||
validationMiddleware(TotalDifficultyNBlockDto, true),
|
||||
this.BlockCount,
|
||||
);
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
@ -970,6 +1005,87 @@ export class BlockchainBlockController {
|
||||
next(new InternalServerErrorException(error));
|
||||
}
|
||||
};
|
||||
|
||||
private BlockCount = async (
|
||||
request: Request,
|
||||
response: Response,
|
||||
next: NextFunction,
|
||||
) => {
|
||||
try {
|
||||
const TotalDifficultyNBlockRequestData: TotalDifficultyNBlockDto =
|
||||
request.query;
|
||||
if (TotalDifficultyNBlockRequestData.Interval) {
|
||||
var timeIntervalQry =
|
||||
"timestamp at time zone '" +
|
||||
process.env.TIME_ZONE +
|
||||
"' > current_date - interval '" +
|
||||
TotalDifficultyNBlockRequestData.Interval +
|
||||
"'";
|
||||
} else if (
|
||||
TotalDifficultyNBlockRequestData.FromDate ||
|
||||
TotalDifficultyNBlockRequestData.ToDate
|
||||
) {
|
||||
let fromdate = moment(TotalDifficultyNBlockRequestData.FromDate)
|
||||
.utc()
|
||||
.format('YYYY-MM-DD');
|
||||
let todate = moment(TotalDifficultyNBlockRequestData.ToDate)
|
||||
.utc()
|
||||
.format('YYYY-MM-DD');
|
||||
|
||||
var timeIntervalQry =
|
||||
"timestamp at time zone '" +
|
||||
process.env.TIME_ZONE +
|
||||
"' BETWEEN SYMMETRIC '" +
|
||||
fromdate +
|
||||
"' AND '" +
|
||||
todate +
|
||||
"'";
|
||||
} else {
|
||||
var timeIntervalQry =
|
||||
"timestamp at time zone '" +
|
||||
process.env.TIME_ZONE +
|
||||
"' > current_date - interval '30 days'";
|
||||
}
|
||||
const BlockQuery = await getConnection()
|
||||
.query(
|
||||
"select 1 as hash, max(total_difficulty_cuckaroo) as total_difficulty_cuckaroo, \
|
||||
max(total_difficulty_cuckatoo) as total_difficulty_cuckatoo, \
|
||||
max(total_difficulty_progpow) as total_difficulty_progpow, \
|
||||
max(total_difficulty_randomx) as total_difficulty_randomx, date(DATE_TRUNC('day', timestamp at time zone '" +
|
||||
process.env.TIME_ZONE +
|
||||
"')) as date, count(hash) as blocks \
|
||||
from blockchain_block where " +
|
||||
timeIntervalQry +
|
||||
"group by DATE_TRUNC('day', timestamp at time zone '" +
|
||||
process.env.TIME_ZONE +
|
||||
"') order by date",
|
||||
)
|
||||
.catch(err_msg => {
|
||||
next(err_msg);
|
||||
});
|
||||
|
||||
let date = [],
|
||||
blockDate = [],
|
||||
blocks = [];
|
||||
|
||||
BlockQuery.forEach(e => {
|
||||
blockDate.push(moment(e.date).format('YYYY-MM-DD'));
|
||||
blocks.push(parseInt(e.blocks));
|
||||
});
|
||||
response.status(200).json({
|
||||
status: 200,
|
||||
timestamp: Date.now(),
|
||||
message: 'Total Difficulty and Blocks Data fetched Successfully',
|
||||
response: {
|
||||
Date: date,
|
||||
Blocks: blocks,
|
||||
blockDate:blockDate
|
||||
},
|
||||
});
|
||||
} catch (error) {
|
||||
next(new InternalServerErrorException(error));
|
||||
}
|
||||
};
|
||||
|
||||
private TotalDifficultyNBlock = async (
|
||||
request: Request,
|
||||
@ -1006,50 +1122,42 @@ export class BlockchainBlockController {
|
||||
todate +
|
||||
"'";
|
||||
} else {
|
||||
var timeIntervalQry =
|
||||
var timeIntervalQry =
|
||||
"timestamp at time zone '" +
|
||||
process.env.TIME_ZONE +
|
||||
"' > current_date - interval '30 days'";
|
||||
"' > current_date - interval '1 day'";
|
||||
|
||||
}
|
||||
const BlockQuery = await getConnection()
|
||||
.query(
|
||||
"select 1 as hash, max(total_difficulty_cuckaroo) as total_difficulty_cuckaroo, \
|
||||
max(total_difficulty_cuckatoo) as total_difficulty_cuckatoo, \
|
||||
max(total_difficulty_progpow) as total_difficulty_progpow, \
|
||||
max(total_difficulty_randomx) as total_difficulty_randomx, date(DATE_TRUNC('day', timestamp at time zone '" +
|
||||
process.env.TIME_ZONE +
|
||||
"')) as date, count(hash) as blocks \
|
||||
from blockchain_block where " +
|
||||
timeIntervalQry +
|
||||
"group by DATE_TRUNC('day', timestamp at time zone '" +
|
||||
process.env.TIME_ZONE +
|
||||
"') order by date",
|
||||
)
|
||||
.catch(err_msg => {
|
||||
next(err_msg);
|
||||
});
|
||||
const TotalDifficultyNBlockQuery = await getConnection()
|
||||
.query(
|
||||
"select 1 as hash, total_difficulty_cuckaroo as total_difficulty_cuckaroo, \
|
||||
total_difficulty_cuckatoo as total_difficulty_cuckatoo, \
|
||||
total_difficulty_progpow as total_difficulty_progpow, \
|
||||
total_difficulty_randomx as total_difficulty_randomx, date(DATE_TRUNC('day', timestamp at time zone '" +
|
||||
total_difficulty_randomx as total_difficulty_randomx, DATE_TRUNC('minute', timestamp at time zone '" +
|
||||
process.env.TIME_ZONE +
|
||||
"')) as date \
|
||||
"') as date \
|
||||
from blockchain_block where " +
|
||||
timeIntervalQry +
|
||||
timeIntervalQry +
|
||||
" order by date",
|
||||
)
|
||||
.catch(err_msg => {
|
||||
next(err_msg);
|
||||
});
|
||||
console.log( "select 1 as hash, total_difficulty_cuckaroo as total_difficulty_cuckaroo, \
|
||||
total_difficulty_cuckatoo as total_difficulty_cuckatoo, \
|
||||
total_difficulty_progpow as total_difficulty_progpow, \
|
||||
total_difficulty_randomx as total_difficulty_randomx, DATE_TRUNC('minute', timestamp at time zone '" +
|
||||
process.env.TIME_ZONE +
|
||||
"') as date \
|
||||
from blockchain_block where " +
|
||||
timeIntervalQry +
|
||||
" order by date");
|
||||
let date = [],
|
||||
blockDate = [],
|
||||
DifficultyCuckaroo = [],
|
||||
DifficultyCuckatoo = [],
|
||||
DifficultyProgpow = [],
|
||||
DifficultyRandomx = [],
|
||||
blocks = [];
|
||||
DifficultyRandomx = [];
|
||||
|
||||
TotalDifficultyNBlockQuery.forEach(e => {
|
||||
//date.indexOf(moment(e.date).format('YYYY-MM-DD')) < 0 ?
|
||||
date.push(moment(e.date).format('YYYY-MM-DD'));
|
||||
@ -1058,18 +1166,13 @@ export class BlockchainBlockController {
|
||||
DifficultyProgpow.push(parseInt(e.total_difficulty_progpow));
|
||||
DifficultyRandomx.push(parseInt(e.total_difficulty_randomx));
|
||||
});
|
||||
BlockQuery.forEach(e => {
|
||||
blockDate.push(moment(e.date).format('YYYY-MM-DD'));
|
||||
blocks.push(parseInt(e.blocks));
|
||||
});
|
||||
|
||||
response.status(200).json({
|
||||
status: 200,
|
||||
timestamp: Date.now(),
|
||||
message: 'Total Difficulty and Blocks Data fetched Successfully',
|
||||
response: {
|
||||
Date: date,
|
||||
Blocks: blocks,
|
||||
blockDate:blockDate,
|
||||
DifficultyCuckaroo: DifficultyCuckaroo,
|
||||
DifficultyCuckatoo: DifficultyCuckatoo,
|
||||
DifficultyProgpow: DifficultyProgpow,
|
||||
|
@ -68,7 +68,7 @@
|
||||
<img src="assets/img/difficulty.png" height="60" />
|
||||
</div>
|
||||
<div class="d-inline-block align-middle ml-2">
|
||||
<span class="">{{'home.DIFFICULTY' | translate}}</span>
|
||||
<span class="">Target Difficulty</span>
|
||||
<h6 class="view_txt">{{(hashdata.BlockchainBlockFetchQuery.Proof == 'Cuckoo') ? (hashdata.BlockchainBlockFetchQuery.TotalCuckoo | number) : (hashdata.BlockchainBlockFetchQuery.Proof == 'RandomX') ? (hashdata.BlockchainBlockFetchQuery.TotalDifficultyRandomx | number) : (hashdata.BlockchainBlockFetchQuery.Proof == 'ProgPow') ? (hashdata.BlockchainBlockFetchQuery.TotalDifficultyProgpow | number) : 0}}</h6>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -12,6 +12,10 @@
|
||||
<epic-explorer-plotly *ngIf="hashdata.data" [data]="hashdata.data" [layout]="hashdata.layout">
|
||||
</epic-explorer-plotly>
|
||||
<div class="day_filter" *ngIf="this.title!='Transactions over time'">
|
||||
|
||||
<a href="JavaScript:void(0);" *ngIf="this.title=='Total Difficulty'" (click)="
|
||||
ChartFromView('', '', '1 day', true, false); selectedItem = 6
|
||||
" id="6" #item6 [ngClass]="{ active: selectedItem == item6.id, txt_primay: true }">1 Day</a>
|
||||
<a href="JavaScript:void(0);" (click)="
|
||||
ChartFromView('', '', '1 week', true, false); selectedItem = 1
|
||||
" id="1" #item1 [ngClass]="{ active: selectedItem == item1.id, txt_primay: true }">1 {{'home.WEEK' | translate}}</a>
|
||||
|
@ -36,7 +36,11 @@ export class GraphDetailComponent implements OnInit {
|
||||
private comp: GraphListComponent,
|
||||
private titleService: Title,
|
||||
public translate: TransServiceService
|
||||
) {}
|
||||
) {
|
||||
if(this.title=='Total Difficulty'){
|
||||
this.selectedItem = 6;
|
||||
}
|
||||
}
|
||||
ngOnInit() {
|
||||
var self = this;
|
||||
var x = setInterval(function() {
|
||||
@ -81,7 +85,7 @@ export class GraphDetailComponent implements OnInit {
|
||||
});
|
||||
break;
|
||||
case 'blocks':
|
||||
this.comp.Difficultyreq().then(res => {
|
||||
this.comp.blockreq().then(res => {
|
||||
this.hashdata = this.comp.barGraphData;
|
||||
this.hashdata.layout.height = 500;
|
||||
this.title = 'Blocks';
|
||||
@ -193,7 +197,7 @@ export class GraphDetailComponent implements OnInit {
|
||||
|
||||
switch (this.chartType) {
|
||||
case 'total-difficulty':
|
||||
this.comp.Difficultyreq(p1, p2, p3, p4, p5).then(res => {
|
||||
this.comp.Difficultyreq(p1, p2, p3).then(res => {
|
||||
this.hashdata = this.comp.linearGraphData;
|
||||
this.hashdata.layout.height = 500;
|
||||
this.title = 'Total Difficulty';
|
||||
@ -210,7 +214,7 @@ export class GraphDetailComponent implements OnInit {
|
||||
});
|
||||
break;
|
||||
case 'blocks':
|
||||
this.comp.Difficultyreq(p1, p2, p3, false, true).then(res => {
|
||||
this.comp.Difficultyreq(p1, p2, p3).then(res => {
|
||||
this.hashdata = this.comp.barGraphData;
|
||||
this.hashdata.layout.height = 500;
|
||||
this.title = 'Blocks';
|
||||
|
@ -25,19 +25,22 @@
|
||||
</div>
|
||||
<div class="day_filter">
|
||||
<a href="JavaScript:void(0);" (click)="
|
||||
Difficultyreq('', '', '1 week', true, false); selectedItem = 1
|
||||
Difficultyreq('', '', '1 day'); selectedItem = 6
|
||||
" id="6" #item6 [ngClass]="{ active: selectedItem == item6.id, txt_primay: true }">1 Day</a>
|
||||
<a href="JavaScript:void(0);" (click)="
|
||||
Difficultyreq('', '', '1 week'); selectedItem = 1
|
||||
" id="1" #item1 [ngClass]="{ active: selectedItem == item1.id, txt_primay: true }">1 {{'home.WEEK' | translate}}</a>
|
||||
<a href="JavaScript:void(0);" (click)="
|
||||
Difficultyreq('', '', '15 days', true, false); selectedItem = 2
|
||||
Difficultyreq('', '', '15 days'); selectedItem = 2
|
||||
" id="2" #item2 [ngClass]="{ active: selectedItem == item2.id, day15_txt: true }">15 {{'home.DAYS' | translate}}</a>
|
||||
<a href="JavaScript:void(0);" (click)="
|
||||
Difficultyreq('', '', '30 days', true, false); selectedItem = 3
|
||||
Difficultyreq('', '', '30 days'); selectedItem = 3
|
||||
" id="3" #item3 [ngClass]="{ active: selectedItem == item3.id, day30_txt: true }">30 {{'home.DAYS' | translate}}</a>
|
||||
<a href="JavaScript:void(0);" (click)="
|
||||
Difficultyreq('', '', '60 days', true, false); selectedItem = 4
|
||||
Difficultyreq('', '', '60 days'); selectedItem = 4
|
||||
" id="4" #item4 [ngClass]="{ active: selectedItem == item4.id, day60_txt: true }">60 {{'home.DAYS' | translate}}</a>
|
||||
<a href="JavaScript:void(0);" (click)="
|
||||
Difficultyreq('', '', '3 months', true, false); selectedItem = 5
|
||||
Difficultyreq('', '', '3 months'); selectedItem = 5
|
||||
" id="5" #item5 [ngClass]="{ active: selectedItem == item5.id, day3m_txt: true }">3 {{'home.MONTHS' | translate}}</a>
|
||||
</div>
|
||||
<div class="explore_all text-right">
|
||||
@ -108,19 +111,19 @@
|
||||
</div>
|
||||
<div class="day_filter">
|
||||
<a href="JavaScript:void(0);" (click)="
|
||||
Difficultyreq('', '', '1 week', false, true); selectedItem3 = 1
|
||||
blockreq('', '', '1 week'); selectedItem3 = 1
|
||||
" id="1" #item31 [ngClass]="{ active: selectedItem3 == item1.id, txt_primay: true }">1 {{'home.WEEK' | translate}}</a>
|
||||
<a href="JavaScript:void(0);" (click)="
|
||||
Difficultyreq('', '', '15 days', false, true); selectedItem3 = 2
|
||||
blockreq('', '', '15 days'); selectedItem3 = 2
|
||||
" id="2" #item32 [ngClass]="{ active: selectedItem3 == item2.id, day15_txt: true }">15 {{'home.DAYS' | translate}}</a>
|
||||
<a href="JavaScript:void(0);" (click)="
|
||||
Difficultyreq('', '', '30 days', false, true); selectedItem3 = 3
|
||||
blockreq('', '', '30 days'); selectedItem3 = 3
|
||||
" id="3" #item33 [ngClass]="{ active: selectedItem3 == item3.id, day30_txt: true }">30 {{'home.DAYS' | translate}}</a>
|
||||
<a href="JavaScript:void(0);" (click)="
|
||||
Difficultyreq('', '', '60 days', false, true); selectedItem3 = 4
|
||||
blockreq('', '', '60 days'); selectedItem3 = 4
|
||||
" id="4" #item34 [ngClass]="{ active: selectedItem3 == item4.id, day60_txt: true }">60 {{'home.DAYS' | translate}}</a>
|
||||
<a href="JavaScript:void(0);" (click)="
|
||||
Difficultyreq('', '', '3 months', false, true); selectedItem3 = 5
|
||||
blockreq('', '', '3 months'); selectedItem3 = 5
|
||||
" id="5" #item35 [ngClass]="{ active: selectedItem3 == item5.id, day3m_txt: true }">3 {{'home.MONTHS' | translate}}</a>
|
||||
</div>
|
||||
<div class="explore_all text-right">
|
||||
|
@ -38,7 +38,7 @@ export class GraphListComponent implements OnInit {
|
||||
public sg_last: any = '';
|
||||
public pg_last: any = '';
|
||||
|
||||
public selectedItem: Number = 3;
|
||||
public selectedItem: Number = 6;
|
||||
public selectedItem3: Number = 3;
|
||||
public selectedItem2: Number = 3;
|
||||
public selectedItem4: Number = 3;
|
||||
@ -70,6 +70,8 @@ export class GraphListComponent implements OnInit {
|
||||
/* Total Difficulty and blocks chart fetching */
|
||||
this.Difficultyreq();
|
||||
|
||||
this.blockreq();
|
||||
|
||||
/* Transcation fee chart fetching */
|
||||
this.Transcationreq();
|
||||
|
||||
@ -374,8 +376,6 @@ export class GraphListComponent implements OnInit {
|
||||
fromDate = '',
|
||||
ToDate = '',
|
||||
interval = '',
|
||||
fordifficult = true,
|
||||
forblocks = true,
|
||||
) {
|
||||
return new Promise((resolve, reject) => {
|
||||
let params = new HttpParams();
|
||||
@ -383,13 +383,12 @@ export class GraphListComponent implements OnInit {
|
||||
params = params.append('ToDate', ToDate);
|
||||
params = params.append('Interval', interval);
|
||||
this.chartService
|
||||
.apiGetRequest(params, '/blockchain_block/totaldiffnblock')
|
||||
.apiGetRequest(params, '/blockchain_block/totaldiff')
|
||||
.subscribe(
|
||||
res => {
|
||||
if (res['status'] == 200) {
|
||||
let DifficultychartDate = res.response.Date;
|
||||
let BlocksChartDate = res.response.blockDate;
|
||||
if (fordifficult) {
|
||||
let DifficultyCuckaroo = res.response.DifficultyCuckaroo;
|
||||
let DifficultyCuckatoo = res.response.DifficultyCuckatoo;
|
||||
let DifficultyProgpow = res.response.DifficultyProgpow;
|
||||
@ -403,12 +402,34 @@ export class GraphListComponent implements OnInit {
|
||||
DifficultyProgpow,
|
||||
DifficultyRandomx
|
||||
);
|
||||
}
|
||||
if (forblocks) {
|
||||
resolve();
|
||||
}
|
||||
},
|
||||
error => {},
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
blockreq(
|
||||
fromDate = '',
|
||||
ToDate = '',
|
||||
interval = '',
|
||||
) {
|
||||
return new Promise((resolve, reject) => {
|
||||
let params = new HttpParams();
|
||||
params = params.append('FromDate', fromDate);
|
||||
params = params.append('ToDate', ToDate);
|
||||
params = params.append('Interval', interval);
|
||||
this.chartService
|
||||
.apiGetRequest(params, '/blockchain_block/blockcount')
|
||||
.subscribe(
|
||||
res => {
|
||||
if (res['status'] == 200) {
|
||||
let DifficultychartDate = res.response.Date;
|
||||
let BlocksChartDate = res.response.blockDate;
|
||||
let Blockval = res.response.Blocks;
|
||||
this.brg_last = Blockval[Blockval.length - 1];
|
||||
this.totalBlocksFunc(BlocksChartDate, Blockval);
|
||||
}
|
||||
resolve();
|
||||
}
|
||||
},
|
||||
|
@ -76,7 +76,7 @@
|
||||
<!-- title="Cuckaroo : {{ hashvalue.target_difficulty_cuckaroo | number }}, Cuckatoo : {{ hashvalue.target_difficulty_cuckatoo | number }}, Progpow : {{ hashvalue.target_difficulty_progpow | number }}, Randomx : {{ hashvalue.target_difficulty_randomx | number }}" -->
|
||||
<div class="block_div">
|
||||
<h6>Difficulty</h6><span
|
||||
class="blck_value">{{(hashvalue.powalgo == 'Cuckoo') ? (hashvalue.totalcuckoo | number) : (hashvalue.powalgo == 'RandomX') ? (hashvalue.blockchain_block_total_difficulty_randomx | number) : (hashvalue.powalgo == 'ProgPow') ? (hashvalue.blockchain_block_total_difficulty_progpow | number) : 0}}</span>
|
||||
class="blck_value">{{(hashvalue.powalgo == 'Cuckoo') ? (hashvalue.target_difficulty_cuckatoo | number) : (hashvalue.powalgo == 'RandomX') ? (hashvalue.target_difficulty_randomx | number) : (hashvalue.powalgo == 'ProgPow') ? (hashvalue.target_difficulty_progpow | number) : 0}}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-6 col-sm-6 col-md-3 tble_col">
|
||||
|
Loading…
Reference in New Issue
Block a user