Difficulty
This commit is contained in:
parent
7ff9209919
commit
61529d04fd
@ -219,6 +219,10 @@ export class BlockchainBlockController {
|
|||||||
* description: Enter the Algorithm Type
|
* description: Enter the Algorithm Type
|
||||||
* in: query
|
* in: query
|
||||||
* type: string
|
* type: string
|
||||||
|
* - name: Difftype
|
||||||
|
* description: Enter the Difficulty Type
|
||||||
|
* in: query
|
||||||
|
* type: string
|
||||||
* responses:
|
* responses:
|
||||||
* 200:
|
* 200:
|
||||||
* description: Total Difficulty fetched successfully
|
* description: Total Difficulty fetched successfully
|
||||||
@ -1133,8 +1137,14 @@ export class BlockchainBlockController {
|
|||||||
|
|
||||||
}
|
}
|
||||||
var alog_type = TotalDifficultyNBlockRequestData.Type;
|
var alog_type = TotalDifficultyNBlockRequestData.Type;
|
||||||
|
var Difftype = TotalDifficultyNBlockRequestData.Difftype;
|
||||||
const TotalDifficultyNBlockQuery = await getConnection()
|
if (TotalDifficultyNBlockRequestData.Interval && TotalDifficultyNBlockRequestData.Interval != '1 day') {
|
||||||
|
var dateFormat = 'YYYY-MM-DD';
|
||||||
|
}else{
|
||||||
|
var dateFormat = 'hh:mm:ss';
|
||||||
|
}
|
||||||
|
if(Difftype == "target"){
|
||||||
|
var TotalDifficultyNBlockQuery = await getConnection()
|
||||||
.query(
|
.query(
|
||||||
"SELECT a.hash, a.tarket_difficulty, a.date FROM(select 1 as hash, (total_difficulty_"+alog_type+" - LAG(total_difficulty_"+alog_type+") OVER (ORDER BY total_difficulty_"+alog_type+")) AS tarket_difficulty, \
|
"SELECT a.hash, a.tarket_difficulty, a.date FROM(select 1 as hash, (total_difficulty_"+alog_type+" - LAG(total_difficulty_"+alog_type+") OVER (ORDER BY total_difficulty_"+alog_type+")) AS tarket_difficulty, \
|
||||||
DATE_TRUNC('minute', timestamp at time zone '" +
|
DATE_TRUNC('minute', timestamp at time zone '" +
|
||||||
@ -1147,13 +1157,49 @@ export class BlockchainBlockController {
|
|||||||
.catch(err_msg => {
|
.catch(err_msg => {
|
||||||
next(err_msg);
|
next(err_msg);
|
||||||
});
|
});
|
||||||
console.log("SELECT a.hash, a.tarket_difficulty, a.date FROM(select 1 as hash, (total_difficulty_"+alog_type+" - LAG(total_difficulty_"+alog_type+") OVER (ORDER BY total_difficulty_"+alog_type+")) AS tarket_difficulty, \
|
}else if(Difftype == "solution"){
|
||||||
DATE_TRUNC('minute', timestamp at time zone '" +
|
var TotalDifficultyNBlockQuery = await getConnection()
|
||||||
process.env.TIME_ZONE +
|
.query(
|
||||||
"') as date \
|
"SELECT a.hash, a.tarket_difficulty, a.date FROM(select 1 as hash, (total_difficulty_"+alog_type+" - LAG(total_difficulty_"+alog_type+") OVER (ORDER BY total_difficulty_"+alog_type+")) AS tarket_difficulty, \
|
||||||
from blockchain_block where " +
|
DATE_TRUNC('minute', timestamp at time zone '" +
|
||||||
timeIntervalQry +
|
process.env.TIME_ZONE +
|
||||||
" order by height) as a WHERE a.tarket_difficulty IS NOT NULL");
|
"') as date \
|
||||||
|
from blockchain_block where " +
|
||||||
|
timeIntervalQry +
|
||||||
|
" order by height) as a WHERE a.tarket_difficulty IS NOT NULL",
|
||||||
|
)
|
||||||
|
.catch(err_msg => {
|
||||||
|
next(err_msg);
|
||||||
|
});
|
||||||
|
}else if(Difftype == "total"){
|
||||||
|
var TotalDifficultyNBlockQuery = await getConnection()
|
||||||
|
.query(
|
||||||
|
"select 1 as hash, total_difficulty_"+alog_type+" as tarket_difficulty, \
|
||||||
|
DATE_TRUNC('minute', timestamp at time zone '" +
|
||||||
|
process.env.TIME_ZONE +
|
||||||
|
"') as date \
|
||||||
|
from blockchain_block where " +
|
||||||
|
timeIntervalQry +
|
||||||
|
" order by height",
|
||||||
|
)
|
||||||
|
.catch(err_msg => {
|
||||||
|
next(err_msg);
|
||||||
|
});
|
||||||
|
}else{
|
||||||
|
var TotalDifficultyNBlockQuery = await getConnection()
|
||||||
|
.query(
|
||||||
|
"SELECT a.hash, a.tarket_difficulty, a.date FROM(select 1 as hash, (total_difficulty_"+alog_type+" - LAG(total_difficulty_"+alog_type+") OVER (ORDER BY total_difficulty_"+alog_type+")) AS tarket_difficulty, \
|
||||||
|
DATE_TRUNC('minute', timestamp at time zone '" +
|
||||||
|
process.env.TIME_ZONE +
|
||||||
|
"') as date \
|
||||||
|
from blockchain_block where " +
|
||||||
|
timeIntervalQry +
|
||||||
|
" order by height) as a WHERE a.tarket_difficulty IS NOT NULL",
|
||||||
|
)
|
||||||
|
.catch(err_msg => {
|
||||||
|
next(err_msg);
|
||||||
|
});
|
||||||
|
}
|
||||||
let date = [],
|
let date = [],
|
||||||
//DifficultyCuckaroo = [],
|
//DifficultyCuckaroo = [],
|
||||||
//DifficultyCuckatoo = [],
|
//DifficultyCuckatoo = [],
|
||||||
@ -1164,7 +1210,7 @@ export class BlockchainBlockController {
|
|||||||
|
|
||||||
TotalDifficultyNBlockQuery.forEach(e => {
|
TotalDifficultyNBlockQuery.forEach(e => {
|
||||||
//date.indexOf(moment(e.date).format('YYYY-MM-DD')) < 0 ?
|
//date.indexOf(moment(e.date).format('YYYY-MM-DD')) < 0 ?
|
||||||
date.push(moment(e.date).format('YYYY-MM-DD'));
|
date.push(moment(e.date).format(dateFormat));
|
||||||
// DifficultyCuckaroo.push(parseInt(e.total_difficulty_cuckaroo));
|
// DifficultyCuckaroo.push(parseInt(e.total_difficulty_cuckaroo));
|
||||||
// DifficultyCuckatoo.push(parseInt(e.total_difficulty_cuckatoo));
|
// DifficultyCuckatoo.push(parseInt(e.total_difficulty_cuckatoo));
|
||||||
// DifficultyProgpow.push(parseInt(e.total_difficulty_progpow));
|
// DifficultyProgpow.push(parseInt(e.total_difficulty_progpow));
|
||||||
|
@ -139,4 +139,7 @@ export class TotalDifficultyNBlockDto {
|
|||||||
@IsString()
|
@IsString()
|
||||||
public Type: string;
|
public Type: string;
|
||||||
|
|
||||||
|
@IsString()
|
||||||
|
public Difftype: string;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user