Target Difficulty
This commit is contained in:
parent
c4a26852b5
commit
fb806d162f
@ -215,6 +215,10 @@ export class BlockchainBlockController {
|
|||||||
* description: Try to give Intevals such as 1 week/ 15 days/ 30 days/ 60 days/ 3 months
|
* description: Try to give Intevals such as 1 week/ 15 days/ 30 days/ 60 days/ 3 months
|
||||||
* in: query
|
* in: query
|
||||||
* type: string
|
* type: string
|
||||||
|
* - name: Type
|
||||||
|
* description: Enter the Algorithm Type
|
||||||
|
* in: query
|
||||||
|
* type: string
|
||||||
* responses:
|
* responses:
|
||||||
* 200:
|
* 200:
|
||||||
* description: Total Difficulty fetched successfully
|
* description: Total Difficulty fetched successfully
|
||||||
@ -1128,43 +1132,44 @@ export class BlockchainBlockController {
|
|||||||
"' > current_date - interval '1 day'";
|
"' > current_date - interval '1 day'";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
var alog_type = TotalDifficultyNBlockRequestData.Type;
|
||||||
|
|
||||||
const TotalDifficultyNBlockQuery = await getConnection()
|
const TotalDifficultyNBlockQuery = await getConnection()
|
||||||
.query(
|
.query(
|
||||||
"select 1 as hash, total_difficulty_cuckaroo as total_difficulty_cuckaroo, \
|
"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, \
|
||||||
total_difficulty_cuckatoo as total_difficulty_cuckatoo, \
|
DATE_TRUNC('minute', timestamp at time zone '" +
|
||||||
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 +
|
process.env.TIME_ZONE +
|
||||||
"') as date \
|
"') as date \
|
||||||
from blockchain_block where " +
|
from blockchain_block where " +
|
||||||
timeIntervalQry +
|
timeIntervalQry +
|
||||||
" order by date",
|
" order by height) as a WHERE a.tarket_difficulty IS NOT NULL",
|
||||||
)
|
)
|
||||||
.catch(err_msg => {
|
.catch(err_msg => {
|
||||||
next(err_msg);
|
next(err_msg);
|
||||||
});
|
});
|
||||||
console.log( "select 1 as hash, total_difficulty_cuckaroo as total_difficulty_cuckaroo, \
|
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, \
|
||||||
total_difficulty_cuckatoo as total_difficulty_cuckatoo, \
|
DATE_TRUNC('minute', timestamp at time zone '" +
|
||||||
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 +
|
process.env.TIME_ZONE +
|
||||||
"') as date \
|
"') as date \
|
||||||
from blockchain_block where " +
|
from blockchain_block where " +
|
||||||
timeIntervalQry +
|
timeIntervalQry +
|
||||||
" order by date");
|
" order by height) as a WHERE a.tarket_difficulty IS NOT NULL");
|
||||||
let date = [],
|
let date = [],
|
||||||
DifficultyCuckaroo = [],
|
//DifficultyCuckaroo = [],
|
||||||
DifficultyCuckatoo = [],
|
//DifficultyCuckatoo = [],
|
||||||
DifficultyProgpow = [],
|
//DifficultyProgpow = [],
|
||||||
DifficultyRandomx = [];
|
//DifficultyRandomx = [];
|
||||||
|
|
||||||
|
TargetDifficulty = [];
|
||||||
|
|
||||||
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('YYYY-MM-DD'));
|
||||||
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));
|
||||||
DifficultyRandomx.push(parseInt(e.total_difficulty_randomx));
|
// DifficultyRandomx.push(parseInt(e.total_difficulty_randomx));
|
||||||
|
TargetDifficulty.push(parseInt(e.tarket_difficulty));
|
||||||
});
|
});
|
||||||
|
|
||||||
response.status(200).json({
|
response.status(200).json({
|
||||||
@ -1173,10 +1178,10 @@ export class BlockchainBlockController {
|
|||||||
message: 'Total Difficulty and Blocks Data fetched Successfully',
|
message: 'Total Difficulty and Blocks Data fetched Successfully',
|
||||||
response: {
|
response: {
|
||||||
Date: date,
|
Date: date,
|
||||||
DifficultyCuckaroo: DifficultyCuckaroo,
|
// DifficultyCuckaroo: DifficultyCuckaroo,
|
||||||
DifficultyCuckatoo: DifficultyCuckatoo,
|
// DifficultyCuckatoo: DifficultyCuckatoo,
|
||||||
DifficultyProgpow: DifficultyProgpow,
|
// DifficultyProgpow: DifficultyProgpow,
|
||||||
DifficultyRandomx: DifficultyRandomx
|
TargetDifficulty: TargetDifficulty
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
@ -135,4 +135,8 @@ export class TotalDifficultyNBlockDto {
|
|||||||
|
|
||||||
@IsString()
|
@IsString()
|
||||||
public Interval: string;
|
public Interval: string;
|
||||||
|
|
||||||
|
@IsString()
|
||||||
|
public Type: string;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user