Merge branch 'master' of https://gitlab.com/epic-tech/explorer2.epic.tech-angular8
This commit is contained in:
commit
d40c0026b7
52
server.ts
52
server.ts
@ -20,6 +20,7 @@ Object.defineProperty(window.document.body.style, "transform", {
|
|||||||
global["document"] = window.document;
|
global["document"] = window.document;
|
||||||
|
|
||||||
import { enableProdMode } from "@angular/core";
|
import { enableProdMode } from "@angular/core";
|
||||||
|
import { Global } from "./server/global";
|
||||||
|
|
||||||
// Express Engine
|
// Express Engine
|
||||||
import { ngExpressEngine } from "@nguniversal/express-engine";
|
import { ngExpressEngine } from "@nguniversal/express-engine";
|
||||||
@ -36,7 +37,8 @@ import {
|
|||||||
getRepository,
|
getRepository,
|
||||||
In,
|
In,
|
||||||
getConnection,
|
getConnection,
|
||||||
getConnectionManager
|
getConnectionManager,
|
||||||
|
createConnections
|
||||||
} from "typeorm";
|
} from "typeorm";
|
||||||
import { resolve } from "path";
|
import { resolve } from "path";
|
||||||
import {
|
import {
|
||||||
@ -45,14 +47,20 @@ import {
|
|||||||
BlockchainKernelController,
|
BlockchainKernelController,
|
||||||
BlockchainOutputController
|
BlockchainOutputController
|
||||||
} from "./server/controllers";
|
} from "./server/controllers";
|
||||||
|
import {
|
||||||
|
BlockchainBlock,
|
||||||
|
BlockchainInput,
|
||||||
|
BlockchainKernel,
|
||||||
|
BlockchainOutput
|
||||||
|
} from "./server/entities";
|
||||||
import { universalGetLatestBlockDetails } from "./server/socket";
|
import { universalGetLatestBlockDetails } from "./server/socket";
|
||||||
import { dbConfig } from "./server/ormconfig";
|
import { dbConfig } from "./server/ormconfig";
|
||||||
import { config } from "dotenv";
|
import { config } from "dotenv";
|
||||||
|
|
||||||
config({ path: resolve(__dirname, "../.env") });
|
config({ path: resolve(__dirname, "../.env") });
|
||||||
|
|
||||||
const connectionManager = getConnectionManager();
|
// const connectionManager = getConnectionManager();
|
||||||
const connection = connectionManager.create(dbConfig);
|
// const connection = connectionManager.create(dbConfig);
|
||||||
|
|
||||||
import { join } from "path";
|
import { join } from "path";
|
||||||
|
|
||||||
@ -140,17 +148,47 @@ app.get("*", (req, res) => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Start up the Node server
|
// Start up the Node server
|
||||||
|
console.log(__dirname);
|
||||||
|
// connection
|
||||||
|
// .connect()
|
||||||
|
// .then(() => {
|
||||||
|
createConnections([ {
|
||||||
|
name: 'Floonet',
|
||||||
|
type: 'postgres',
|
||||||
|
host: process.env.FLOONET_DB_HOST,
|
||||||
|
port: Number(process.env.FLOONET_DB_PORT),
|
||||||
|
username: process.env.FLOONET_DB_USERNAME,
|
||||||
|
password: process.env.FLOONET_DB_PASSWORD,
|
||||||
|
database: process.env.FLOONET_DB_DATABASE,
|
||||||
|
synchronize: false,
|
||||||
|
logging: false,
|
||||||
|
entities: [BlockchainBlock,
|
||||||
|
BlockchainInput,
|
||||||
|
BlockchainKernel,
|
||||||
|
BlockchainOutput],
|
||||||
|
}, {
|
||||||
|
name: 'Testnet',
|
||||||
|
type: 'postgres',
|
||||||
|
host: process.env.TESTNET_DB_HOST,
|
||||||
|
port: Number(process.env.TESTNET_DB_PORT),
|
||||||
|
username: process.env.TESTNET_DB_USERNAME,
|
||||||
|
password: process.env.TESTNET_DB_PASSWORD,
|
||||||
|
database: process.env.TESTNET_DB_DATABASE,
|
||||||
|
synchronize: false,
|
||||||
|
logging: false,
|
||||||
|
entities: [BlockchainBlock,
|
||||||
|
BlockchainInput,
|
||||||
|
BlockchainKernel,
|
||||||
|
BlockchainOutput],
|
||||||
|
}]).then(async () => {
|
||||||
|
|
||||||
connection
|
|
||||||
.connect()
|
|
||||||
.then(() => {
|
|
||||||
const server = app.listen(PORT, () => {
|
const server = app.listen(PORT, () => {
|
||||||
console.log(`Node Express server listening on http://localhost:${PORT}`);
|
console.log(`Node Express server listening on http://localhost:${PORT}`);
|
||||||
});
|
});
|
||||||
const io = require("socket.io").listen(server);
|
const io = require("socket.io").listen(server);
|
||||||
io.sockets.on("connection", socket => {
|
io.sockets.on("connection", socket => {
|
||||||
// setInterval(function() {
|
// setInterval(function() {
|
||||||
// //universalGetLatestBlockDetails(socket);
|
// universalGetLatestBlockDetails(socket);
|
||||||
// },1000);
|
// },1000);
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import express from 'express';
|
import express from 'express';
|
||||||
|
import { Global } from "../global";
|
||||||
import { Request, Response, NextFunction } from 'express';
|
import { Request, Response, NextFunction } from 'express';
|
||||||
import { getRepository, getConnection } from 'typeorm';
|
import { getRepository, getConnection } from 'typeorm';
|
||||||
import { validationMiddleware } from '../middlewares';
|
import { validationMiddleware } from '../middlewares';
|
||||||
@ -646,7 +647,7 @@ export class BlockchainBlockController {
|
|||||||
) => {
|
) => {
|
||||||
try {
|
try {
|
||||||
const BlockchainBlockRequestData: BlockchainBlockCreateDto = request.body;
|
const BlockchainBlockRequestData: BlockchainBlockCreateDto = request.body;
|
||||||
const BlockchainBlockCreateQuery = await getRepository(
|
const BlockchainBlockCreateQuery = await getConnection(Global.network).getRepository(
|
||||||
BlockchainBlock,
|
BlockchainBlock,
|
||||||
).save(BlockchainBlockRequestData);
|
).save(BlockchainBlockRequestData);
|
||||||
response.status(200).json({
|
response.status(200).json({
|
||||||
@ -666,7 +667,7 @@ export class BlockchainBlockController {
|
|||||||
next: NextFunction,
|
next: NextFunction,
|
||||||
) => {
|
) => {
|
||||||
try {
|
try {
|
||||||
var BlockchainBlockFetchQuery = await getRepository(
|
var BlockchainBlockFetchQuery = await getConnection(Global.network).getRepository(
|
||||||
BlockchainBlock,
|
BlockchainBlock,
|
||||||
).findOne({
|
).findOne({
|
||||||
select: [
|
select: [
|
||||||
@ -691,7 +692,7 @@ export class BlockchainBlockController {
|
|||||||
paramVal.length <= 10 &&
|
paramVal.length <= 10 &&
|
||||||
paramVal <= 2147483647
|
paramVal <= 2147483647
|
||||||
) {
|
) {
|
||||||
var BlockchainBlockFetchQuery = await getRepository(
|
var BlockchainBlockFetchQuery = await getConnection(Global.network).getRepository(
|
||||||
BlockchainBlock,
|
BlockchainBlock,
|
||||||
).findOne({
|
).findOne({
|
||||||
select: [
|
select: [
|
||||||
@ -713,21 +714,21 @@ export class BlockchainBlockController {
|
|||||||
if (!BlockchainBlockFetchQuery) {
|
if (!BlockchainBlockFetchQuery) {
|
||||||
next(new NoDataFoundException());
|
next(new NoDataFoundException());
|
||||||
}else{
|
}else{
|
||||||
const BlockchainBlockInputFetchQuery = await getRepository(
|
const BlockchainBlockInputFetchQuery = await getConnection(Global.network).getRepository(
|
||||||
BlockchainInput,
|
BlockchainInput,
|
||||||
).find({
|
).find({
|
||||||
select: ['Data'],
|
select: ['Data'],
|
||||||
where: { BlockId: BlockchainBlockFetchQuery.Hash },
|
where: { BlockId: BlockchainBlockFetchQuery.Hash },
|
||||||
});
|
});
|
||||||
|
|
||||||
const BlockchainBlockOutputFetchQuery = await getRepository(
|
const BlockchainBlockOutputFetchQuery = await getConnection(Global.network).getRepository(
|
||||||
BlockchainOutput,
|
BlockchainOutput,
|
||||||
).find({
|
).find({
|
||||||
select: ['OutputType', 'Commit', 'Spent'],
|
select: ['OutputType', 'Commit', 'Spent'],
|
||||||
where: { BlockId: BlockchainBlockFetchQuery.Hash },
|
where: { BlockId: BlockchainBlockFetchQuery.Hash },
|
||||||
});
|
});
|
||||||
|
|
||||||
const BlockchainBlockKernalFetchQuery = await getRepository(
|
const BlockchainBlockKernalFetchQuery = await getConnection(Global.network).getRepository(
|
||||||
BlockchainKernel,
|
BlockchainKernel,
|
||||||
).find({
|
).find({
|
||||||
select: ['Features', 'Fee', 'LockHeight'],
|
select: ['Features', 'Fee', 'LockHeight'],
|
||||||
@ -801,7 +802,7 @@ export class BlockchainBlockController {
|
|||||||
// }
|
// }
|
||||||
|
|
||||||
if (BlockchainBlockFetchQuery.PreviousId) {
|
if (BlockchainBlockFetchQuery.PreviousId) {
|
||||||
const BlockchainPreviousBlockFetchQuery = await getRepository(
|
const BlockchainPreviousBlockFetchQuery = await getConnection(Global.network).getRepository(
|
||||||
BlockchainBlock,
|
BlockchainBlock,
|
||||||
).findOne({
|
).findOne({
|
||||||
select: ['TotalDifficultyCuckaroo', 'TotalDifficultyCuckatoo', 'TotalDifficultyProgpow', 'TotalDifficultyRandomx'],
|
select: ['TotalDifficultyCuckaroo', 'TotalDifficultyCuckatoo', 'TotalDifficultyProgpow', 'TotalDifficultyRandomx'],
|
||||||
@ -875,7 +876,7 @@ export class BlockchainBlockController {
|
|||||||
) => {
|
) => {
|
||||||
try {
|
try {
|
||||||
const BlockchainBlockRequestData: BlockchainBlockUpdateDto = request.body;
|
const BlockchainBlockRequestData: BlockchainBlockUpdateDto = request.body;
|
||||||
const BlockchainBlockUpdateQuery = await getRepository(
|
const BlockchainBlockUpdateQuery = await getConnection(Global.network).getRepository(
|
||||||
BlockchainBlock,
|
BlockchainBlock,
|
||||||
).update(BlockchainBlockRequestData.Hash, BlockchainBlockRequestData);
|
).update(BlockchainBlockRequestData.Hash, BlockchainBlockRequestData);
|
||||||
response.status(200).json({
|
response.status(200).json({
|
||||||
@ -895,7 +896,7 @@ export class BlockchainBlockController {
|
|||||||
next: NextFunction,
|
next: NextFunction,
|
||||||
) => {
|
) => {
|
||||||
try {
|
try {
|
||||||
const BlockchainBlockDeleteQuery = await getRepository(
|
const BlockchainBlockDeleteQuery = await getConnection(Global.network).getRepository(
|
||||||
BlockchainBlock,
|
BlockchainBlock,
|
||||||
).delete(request.params.Hash);
|
).delete(request.params.Hash);
|
||||||
BlockchainBlockDeleteQuery
|
BlockchainBlockDeleteQuery
|
||||||
@ -931,7 +932,7 @@ export class BlockchainBlockController {
|
|||||||
// next(new IntegerValidationException('MaxPages'));
|
// next(new IntegerValidationException('MaxPages'));
|
||||||
// }
|
// }
|
||||||
else {
|
else {
|
||||||
const BlockchainBlockCountQuery = await getRepository(BlockchainBlock)
|
const BlockchainBlockCountQuery = await getConnection(Global.network).getRepository(BlockchainBlock)
|
||||||
.createQueryBuilder()
|
.createQueryBuilder()
|
||||||
.getCount();
|
.getCount();
|
||||||
if (BlockchainBlockCountQuery) {
|
if (BlockchainBlockCountQuery) {
|
||||||
@ -950,7 +951,7 @@ export class BlockchainBlockController {
|
|||||||
// Hash: 'DESC',
|
// Hash: 'DESC',
|
||||||
// },
|
// },
|
||||||
// });
|
// });
|
||||||
const BlockchainBlockPaginationQuery = await getRepository(
|
const BlockchainBlockPaginationQuery = await getConnection(Global.network).getRepository(
|
||||||
BlockchainBlock,
|
BlockchainBlock,
|
||||||
)
|
)
|
||||||
.createQueryBuilder('blockchain_block')
|
.createQueryBuilder('blockchain_block')
|
||||||
@ -995,7 +996,7 @@ export class BlockchainBlockController {
|
|||||||
let BlockchainBlockResult = BlockchainBlockPaginationQuery.raw;
|
let BlockchainBlockResult = BlockchainBlockPaginationQuery.raw;
|
||||||
let lastElemt =
|
let lastElemt =
|
||||||
BlockchainBlockResult[BlockchainBlockResult.length - 1];
|
BlockchainBlockResult[BlockchainBlockResult.length - 1];
|
||||||
const BlockchainPreviousBlockFetchQuery = await getRepository(
|
const BlockchainPreviousBlockFetchQuery = await getConnection(Global.network).getRepository(
|
||||||
BlockchainBlock,
|
BlockchainBlock,
|
||||||
).findOne({
|
).findOne({
|
||||||
select: ['TotalDifficultyCuckaroo', 'TotalDifficultyCuckatoo', 'TotalDifficultyProgpow', 'TotalDifficultyRandomx'],
|
select: ['TotalDifficultyCuckaroo', 'TotalDifficultyCuckatoo', 'TotalDifficultyProgpow', 'TotalDifficultyRandomx'],
|
||||||
@ -1113,7 +1114,7 @@ export class BlockchainBlockController {
|
|||||||
process.env.TIME_ZONE +
|
process.env.TIME_ZONE +
|
||||||
"' > current_date - interval '1 day'";
|
"' > current_date - interval '1 day'";
|
||||||
}
|
}
|
||||||
const BlockQuery = await getConnection()
|
const BlockQuery = await getConnection(Global.network)
|
||||||
.query(
|
.query(
|
||||||
"select 1 as hash, max(total_difficulty_cuckaroo) as total_difficulty_cuckaroo, \
|
"select 1 as hash, max(total_difficulty_cuckaroo) as total_difficulty_cuckaroo, \
|
||||||
max(total_difficulty_cuckatoo) as total_difficulty_cuckatoo, \
|
max(total_difficulty_cuckatoo) as total_difficulty_cuckatoo, \
|
||||||
@ -1205,7 +1206,7 @@ export class BlockchainBlockController {
|
|||||||
var tickFormat = '%H-%M';
|
var tickFormat = '%H-%M';
|
||||||
}
|
}
|
||||||
if(Difftype == "target"){
|
if(Difftype == "target"){
|
||||||
var TotalDifficultyNBlockQuery = await getConnection()
|
var TotalDifficultyNBlockQuery = await getConnection(Global.network)
|
||||||
.query(
|
.query(
|
||||||
"SELECT a.hash, a.total_difficulty_randomx, a.total_difficulty_cuckatoo,a.total_difficulty_progpow, a.date FROM(select 1 as hash, (total_difficulty_cuckatoo - LAG(total_difficulty_cuckatoo) OVER (ORDER BY total_difficulty_cuckatoo)) AS total_difficulty_cuckatoo, \
|
"SELECT a.hash, a.total_difficulty_randomx, a.total_difficulty_cuckatoo,a.total_difficulty_progpow, a.date FROM(select 1 as hash, (total_difficulty_cuckatoo - LAG(total_difficulty_cuckatoo) OVER (ORDER BY total_difficulty_cuckatoo)) AS total_difficulty_cuckatoo, \
|
||||||
(total_difficulty_progpow - LAG(total_difficulty_progpow) OVER (ORDER BY total_difficulty_progpow)) AS total_difficulty_progpow , \
|
(total_difficulty_progpow - LAG(total_difficulty_progpow) OVER (ORDER BY total_difficulty_progpow)) AS total_difficulty_progpow , \
|
||||||
@ -1221,7 +1222,7 @@ export class BlockchainBlockController {
|
|||||||
next(err_msg);
|
next(err_msg);
|
||||||
});
|
});
|
||||||
}else if(Difftype == "total"){
|
}else if(Difftype == "total"){
|
||||||
var TotalDifficultyNBlockQuery = await getConnection()
|
var TotalDifficultyNBlockQuery = await getConnection(Global.network)
|
||||||
.query(
|
.query(
|
||||||
"select 1 as hash, total_difficulty_cuckatoo,total_difficulty_progpow,total_difficulty_randomx, \
|
"select 1 as hash, total_difficulty_cuckatoo,total_difficulty_progpow,total_difficulty_randomx, \
|
||||||
DATE_TRUNC('minute', timestamp at time zone '" +
|
DATE_TRUNC('minute', timestamp at time zone '" +
|
||||||
@ -1361,7 +1362,7 @@ export class BlockchainBlockController {
|
|||||||
process.env.TIME_ZONE +
|
process.env.TIME_ZONE +
|
||||||
"' > current_date - interval '30 days'";
|
"' > current_date - interval '30 days'";
|
||||||
}
|
}
|
||||||
const stackNBlockQuery = await getConnection()
|
const stackNBlockQuery = await getConnection(Global.network)
|
||||||
.query(
|
.query(
|
||||||
"select 1 as hash, date(DATE_TRUNC('day', timestamp at time zone '" +
|
"select 1 as hash, date(DATE_TRUNC('day', timestamp at time zone '" +
|
||||||
process.env.TIME_ZONE +
|
process.env.TIME_ZONE +
|
||||||
@ -1445,7 +1446,7 @@ export class BlockchainBlockController {
|
|||||||
process.env.TIME_ZONE +
|
process.env.TIME_ZONE +
|
||||||
"' > current_date - interval '30 days'";
|
"' > current_date - interval '30 days'";
|
||||||
}
|
}
|
||||||
const stackNBlockQuery = await getConnection()
|
const stackNBlockQuery = await getConnection(Global.network)
|
||||||
.query(
|
.query(
|
||||||
"SELECT hash,total_edge_bits, RandomX, Cuckoo, ProgPow, Round(RandomX * 100.0 / total_edge_bits,2) AS RandomXper, Round(Cuckoo * 100.0 / total_edge_bits,2) AS Cuckooper, Round(ProgPow * 100.0 / total_edge_bits,2) AS ProgPowper from (select 1 as hash, COUNT(edge_bits) AS total_edge_bits, \
|
"SELECT hash,total_edge_bits, RandomX, Cuckoo, ProgPow, Round(RandomX * 100.0 / total_edge_bits,2) AS RandomXper, Round(Cuckoo * 100.0 / total_edge_bits,2) AS Cuckooper, Round(ProgPow * 100.0 / total_edge_bits,2) AS ProgPowper from (select 1 as hash, COUNT(edge_bits) AS total_edge_bits, \
|
||||||
Count( CASE WHEN proof = 'RandomX' THEN 1 ELSE NULL END) AS RandomX,\
|
Count( CASE WHEN proof = 'RandomX' THEN 1 ELSE NULL END) AS RandomX,\
|
||||||
@ -1516,7 +1517,7 @@ export class BlockchainBlockController {
|
|||||||
var seriesquery = "now() - interval '30 days', now()";
|
var seriesquery = "now() - interval '30 days', now()";
|
||||||
}
|
}
|
||||||
|
|
||||||
const HashRateQueryAR29 = await getConnection()
|
const HashRateQueryAR29 = await getConnection(Global.network)
|
||||||
.query(
|
.query(
|
||||||
'with hours as ( SELECT hour::date from generate_series(' +
|
'with hours as ( SELECT hour::date from generate_series(' +
|
||||||
seriesquery +
|
seriesquery +
|
||||||
@ -1527,7 +1528,7 @@ export class BlockchainBlockController {
|
|||||||
.catch(err_msg => {
|
.catch(err_msg => {
|
||||||
next(err_msg);
|
next(err_msg);
|
||||||
});
|
});
|
||||||
const HashRateQueryAT31 = await getConnection()
|
const HashRateQueryAT31 = await getConnection(Global.network)
|
||||||
.query(
|
.query(
|
||||||
'with hours as ( SELECT hour::date from generate_series(' +
|
'with hours as ( SELECT hour::date from generate_series(' +
|
||||||
seriesquery +
|
seriesquery +
|
||||||
@ -1583,14 +1584,14 @@ export class BlockchainBlockController {
|
|||||||
letest_block_num = '',
|
letest_block_num = '',
|
||||||
letest_block_duration = '';
|
letest_block_duration = '';
|
||||||
|
|
||||||
const BlockchainLatestBlockQuery = await getConnection()
|
const BlockchainLatestBlockQuery = await getConnection(Global.network)
|
||||||
.query(
|
.query(
|
||||||
'SELECT timestamp,height,edge_bits,hash,secondary_scaling, previous_id, total_difficulty_cuckaroo, total_difficulty_cuckatoo, total_difficulty_progpow, total_difficulty_randomx FROM blockchain_block ORDER BY timestamp DESC LIMIT 1',
|
'SELECT timestamp,height,edge_bits,hash,secondary_scaling, previous_id, total_difficulty_cuckaroo, total_difficulty_cuckatoo, total_difficulty_progpow, total_difficulty_randomx FROM blockchain_block ORDER BY timestamp DESC LIMIT 1',
|
||||||
)
|
)
|
||||||
.catch(err_msg => {
|
.catch(err_msg => {
|
||||||
next(err_msg);
|
next(err_msg);
|
||||||
});
|
});
|
||||||
const BlockchainPreviousBlockQuery = await getConnection()
|
const BlockchainPreviousBlockQuery = await getConnection(Global.network)
|
||||||
.query(
|
.query(
|
||||||
'SELECT total_difficulty_cuckaroo, total_difficulty_cuckatoo, total_difficulty_progpow, total_difficulty_randomx FROM blockchain_block WHERE hash=' +
|
'SELECT total_difficulty_cuckaroo, total_difficulty_cuckatoo, total_difficulty_progpow, total_difficulty_randomx FROM blockchain_block WHERE hash=' +
|
||||||
"'" +
|
"'" +
|
||||||
@ -1825,7 +1826,7 @@ let remaining_height = 0;
|
|||||||
} else {
|
} else {
|
||||||
var timeIntervalQry = "timestamp > current_date - interval '30 days'";
|
var timeIntervalQry = "timestamp > current_date - interval '30 days'";
|
||||||
}
|
}
|
||||||
const BlockchainBlockPerSecondQuery = await getConnection()
|
const BlockchainBlockPerSecondQuery = await getConnection(Global.network)
|
||||||
.query(
|
.query(
|
||||||
"select date(DATE_TRUNC('day', timestamp)) as date, count(hash) as blocks, 86400/count(hash) as period \
|
"select date(DATE_TRUNC('day', timestamp)) as date, count(hash) as blocks, 86400/count(hash) as period \
|
||||||
from blockchain_block where " +
|
from blockchain_block where " +
|
||||||
@ -1900,7 +1901,7 @@ let remaining_height = 0;
|
|||||||
const BLOCK_ERA_6_ONWARDS = DAY_HEIGHT * 1460;
|
const BLOCK_ERA_6_ONWARDS = DAY_HEIGHT * 1460;
|
||||||
/// Block Reward that will be assigned after we change from era 5 to era 6.
|
/// Block Reward that will be assigned after we change from era 5 to era 6.
|
||||||
const BASE_REWARD_ERA_6_ONWARDS = 0.15625;
|
const BASE_REWARD_ERA_6_ONWARDS = 0.15625;
|
||||||
const BlockchainBlockPerSecondQuery = await getConnection()
|
const BlockchainBlockPerSecondQuery = await getConnection(Global.network)
|
||||||
.query(
|
.query(
|
||||||
'select x.timestamp, SUM(x.reward) as total_reward_per_day \
|
'select x.timestamp, SUM(x.reward) as total_reward_per_day \
|
||||||
from (SELECT DISTINCT height, hash, CAST(timestamp AS DATE), \
|
from (SELECT DISTINCT height, hash, CAST(timestamp AS DATE), \
|
||||||
@ -2008,7 +2009,7 @@ let remaining_height = 0;
|
|||||||
process.env.TIME_ZONE +
|
process.env.TIME_ZONE +
|
||||||
"' > current_date - interval '30 days'";
|
"' > current_date - interval '30 days'";
|
||||||
}
|
}
|
||||||
const BlockMineChartQuery = await getConnection()
|
const BlockMineChartQuery = await getConnection(Global.network)
|
||||||
.query(
|
.query(
|
||||||
"SELECT hash, date , total_edge_bits, RandomX, Cuckoo, ProgPow, Round(RandomX * 100.0 / total_edge_bits,2) AS RandomXper, Round(Cuckoo * 100.0 / total_edge_bits,2) AS Cuckooper, Round(ProgPow * 100.0 / total_edge_bits,2) AS ProgPowper \
|
"SELECT hash, date , total_edge_bits, RandomX, Cuckoo, ProgPow, Round(RandomX * 100.0 / total_edge_bits,2) AS RandomXper, Round(Cuckoo * 100.0 / total_edge_bits,2) AS Cuckooper, Round(ProgPow * 100.0 / total_edge_bits,2) AS ProgPowper \
|
||||||
FROM (SELECT 1 as hash, \
|
FROM (SELECT 1 as hash, \
|
||||||
@ -2043,7 +2044,7 @@ let remaining_height = 0;
|
|||||||
Cuckooper.push(parseFloat(e.cuckooper));
|
Cuckooper.push(parseFloat(e.cuckooper));
|
||||||
ProgPowper.push(parseFloat(e.progpowper));
|
ProgPowper.push(parseFloat(e.progpowper));
|
||||||
RandomX.push(parseInt(e.randomx));
|
RandomX.push(parseInt(e.randomx));
|
||||||
Cuckoo.push(parseInt(e.cuckatoo));
|
Cuckoo.push(parseInt(e.cuckoo));
|
||||||
ProgPow.push(parseInt(e.progpow));
|
ProgPow.push(parseInt(e.progpow));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -1,11 +1,13 @@
|
|||||||
import express from 'express';
|
import express from 'express';
|
||||||
import { Request, Response, NextFunction } from 'express';
|
import { Request, Response, NextFunction } from 'express';
|
||||||
import { getRepository } from 'typeorm';
|
import { getRepository,getConnection } from 'typeorm';
|
||||||
import { validationMiddleware } from '../middlewares';
|
import { validationMiddleware } from '../middlewares';
|
||||||
import {
|
import {
|
||||||
InternalServerErrorException,
|
InternalServerErrorException,
|
||||||
NoDataFoundException,
|
NoDataFoundException,
|
||||||
} from '../exceptions';
|
} from '../exceptions';
|
||||||
|
import { Global } from "../global";
|
||||||
|
|
||||||
import { BlockchainInput } from '../entities';
|
import { BlockchainInput } from '../entities';
|
||||||
import {
|
import {
|
||||||
BlockchainInputCreateDto,
|
BlockchainInputCreateDto,
|
||||||
@ -195,7 +197,7 @@ export class BlockchainInputController {
|
|||||||
) => {
|
) => {
|
||||||
try {
|
try {
|
||||||
const BlockchainInputRequestData: BlockchainInputCreateDto = request.body;
|
const BlockchainInputRequestData: BlockchainInputCreateDto = request.body;
|
||||||
const BlockchainInputCreateQuery = await getRepository(
|
const BlockchainInputCreateQuery = await getConnection(Global.network).getRepository(
|
||||||
BlockchainInput,
|
BlockchainInput,
|
||||||
).save(BlockchainInputRequestData);
|
).save(BlockchainInputRequestData);
|
||||||
response.status(200).json({
|
response.status(200).json({
|
||||||
@ -215,7 +217,7 @@ export class BlockchainInputController {
|
|||||||
next: NextFunction,
|
next: NextFunction,
|
||||||
) => {
|
) => {
|
||||||
try {
|
try {
|
||||||
const BlockchainInputFetchQuery = await getRepository(
|
const BlockchainInputFetchQuery = await getConnection(Global.network).getRepository(
|
||||||
BlockchainInput,
|
BlockchainInput,
|
||||||
).findOne({
|
).findOne({
|
||||||
where: { id: request.params.id },
|
where: { id: request.params.id },
|
||||||
@ -240,7 +242,7 @@ export class BlockchainInputController {
|
|||||||
) => {
|
) => {
|
||||||
try {
|
try {
|
||||||
const BlockchainInputRequestData: BlockchainInputUpdateDto = request.body;
|
const BlockchainInputRequestData: BlockchainInputUpdateDto = request.body;
|
||||||
const BlockchainInputUpdateQuery = await getRepository(
|
const BlockchainInputUpdateQuery = await getConnection(Global.network).getRepository(
|
||||||
BlockchainInput,
|
BlockchainInput,
|
||||||
).update(BlockchainInputRequestData.Id, BlockchainInputRequestData);
|
).update(BlockchainInputRequestData.Id, BlockchainInputRequestData);
|
||||||
response.status(200).json({
|
response.status(200).json({
|
||||||
@ -260,7 +262,7 @@ export class BlockchainInputController {
|
|||||||
next: NextFunction,
|
next: NextFunction,
|
||||||
) => {
|
) => {
|
||||||
try {
|
try {
|
||||||
const BlockchainInputDeleteQuery = await getRepository(
|
const BlockchainInputDeleteQuery = await getConnection(Global.network).getRepository(
|
||||||
BlockchainInput,
|
BlockchainInput,
|
||||||
).delete(request.params.Id);
|
).delete(request.params.Id);
|
||||||
BlockchainInputDeleteQuery
|
BlockchainInputDeleteQuery
|
||||||
@ -284,7 +286,7 @@ export class BlockchainInputController {
|
|||||||
try {
|
try {
|
||||||
const BlockchainInputRequestData: BlockchainInputPaginationDto =
|
const BlockchainInputRequestData: BlockchainInputPaginationDto =
|
||||||
request.query;
|
request.query;
|
||||||
const BlockchainInputCountQuery = await getRepository(
|
const BlockchainInputCountQuery = await getConnection(Global.network).getRepository(
|
||||||
BlockchainInput,
|
BlockchainInput,
|
||||||
).findAndCount({});
|
).findAndCount({});
|
||||||
if (BlockchainInputCountQuery[1]) {
|
if (BlockchainInputCountQuery[1]) {
|
||||||
@ -294,7 +296,7 @@ export class BlockchainInputController {
|
|||||||
BlockchainInputRequestData.PageSize,
|
BlockchainInputRequestData.PageSize,
|
||||||
BlockchainInputRequestData.MaxPages,
|
BlockchainInputRequestData.MaxPages,
|
||||||
);
|
);
|
||||||
const BlockchainInputPaginationQuery = await getRepository(
|
const BlockchainInputPaginationQuery = await getConnection(Global.network).getRepository(
|
||||||
BlockchainInput,
|
BlockchainInput,
|
||||||
).find({
|
).find({
|
||||||
skip: PaginationReponseData.startIndex,
|
skip: PaginationReponseData.startIndex,
|
||||||
|
@ -2,6 +2,7 @@ import express from 'express';
|
|||||||
import { Request, Response, NextFunction } from 'express';
|
import { Request, Response, NextFunction } from 'express';
|
||||||
import { getRepository, getConnection } from 'typeorm';
|
import { getRepository, getConnection } from 'typeorm';
|
||||||
import { validationMiddleware } from '../middlewares';
|
import { validationMiddleware } from '../middlewares';
|
||||||
|
import { Global } from "../global";
|
||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
import {
|
import {
|
||||||
InternalServerErrorException,
|
InternalServerErrorException,
|
||||||
@ -144,6 +145,30 @@ export class BlockchainKernelController {
|
|||||||
this.Translator,
|
this.Translator,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @swagger
|
||||||
|
* /epic_explorer/v1/network:
|
||||||
|
* get:
|
||||||
|
* tags:
|
||||||
|
* - name: Network | Network CONTROLLER
|
||||||
|
* summary: change a network
|
||||||
|
* description: change a network
|
||||||
|
* consumes:
|
||||||
|
* - application/json
|
||||||
|
* produces:
|
||||||
|
* - application/json
|
||||||
|
* parameters:
|
||||||
|
* - name: network
|
||||||
|
* responses:
|
||||||
|
* 200:
|
||||||
|
* description: Network Changed successfully
|
||||||
|
*/
|
||||||
|
this.router.get(
|
||||||
|
`${this.path}/network`,
|
||||||
|
this.changeNetwok,
|
||||||
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @swagger
|
* @swagger
|
||||||
* /epic_explorer/v1/getpeers:
|
* /epic_explorer/v1/getpeers:
|
||||||
@ -356,7 +381,7 @@ export class BlockchainKernelController {
|
|||||||
try {
|
try {
|
||||||
const BlockchainKernelRequestData: BlockchainKernelCreateDto =
|
const BlockchainKernelRequestData: BlockchainKernelCreateDto =
|
||||||
request.body;
|
request.body;
|
||||||
const BlockchainKernelCreateQuery = await getRepository(
|
const BlockchainKernelCreateQuery = await getConnection(Global.network).getRepository(
|
||||||
BlockchainKernel,
|
BlockchainKernel,
|
||||||
).save(BlockchainKernelRequestData);
|
).save(BlockchainKernelRequestData);
|
||||||
response.status(200).json({
|
response.status(200).json({
|
||||||
@ -376,7 +401,7 @@ export class BlockchainKernelController {
|
|||||||
next: NextFunction,
|
next: NextFunction,
|
||||||
) => {
|
) => {
|
||||||
try {
|
try {
|
||||||
const BlockchainKernelFetchQuery = await getRepository(
|
const BlockchainKernelFetchQuery = await getConnection(Global.network).getRepository(
|
||||||
BlockchainKernel,
|
BlockchainKernel,
|
||||||
).findOne({
|
).findOne({
|
||||||
where: { id: request.params.id },
|
where: { id: request.params.id },
|
||||||
@ -402,7 +427,7 @@ export class BlockchainKernelController {
|
|||||||
try {
|
try {
|
||||||
const BlockchainKernelRequestData: BlockchainKernelUpdateDto =
|
const BlockchainKernelRequestData: BlockchainKernelUpdateDto =
|
||||||
request.body;
|
request.body;
|
||||||
const BlockchainKernelUpdateQuery = await getRepository(
|
const BlockchainKernelUpdateQuery = await getConnection(Global.network).getRepository(
|
||||||
BlockchainKernel,
|
BlockchainKernel,
|
||||||
).update(BlockchainKernelRequestData.Id, BlockchainKernelRequestData);
|
).update(BlockchainKernelRequestData.Id, BlockchainKernelRequestData);
|
||||||
response.status(200).json({
|
response.status(200).json({
|
||||||
@ -422,7 +447,7 @@ export class BlockchainKernelController {
|
|||||||
next: NextFunction,
|
next: NextFunction,
|
||||||
) => {
|
) => {
|
||||||
try {
|
try {
|
||||||
const BlockchainKernelDeleteQuery = await getRepository(
|
const BlockchainKernelDeleteQuery = await getConnection(Global.network).getRepository(
|
||||||
BlockchainKernel,
|
BlockchainKernel,
|
||||||
).delete(request.params.Id);
|
).delete(request.params.Id);
|
||||||
BlockchainKernelDeleteQuery
|
BlockchainKernelDeleteQuery
|
||||||
@ -446,7 +471,7 @@ export class BlockchainKernelController {
|
|||||||
try {
|
try {
|
||||||
const BlockchainKernelRequestData: BlockchainKernelPaginationDto =
|
const BlockchainKernelRequestData: BlockchainKernelPaginationDto =
|
||||||
request.query;
|
request.query;
|
||||||
const BlockchainKernelCountQuery = await getRepository(
|
const BlockchainKernelCountQuery = await getConnection(Global.network).getRepository(
|
||||||
BlockchainKernel,
|
BlockchainKernel,
|
||||||
).findAndCount({});
|
).findAndCount({});
|
||||||
if (BlockchainKernelCountQuery[1]) {
|
if (BlockchainKernelCountQuery[1]) {
|
||||||
@ -456,7 +481,7 @@ export class BlockchainKernelController {
|
|||||||
BlockchainKernelRequestData.PageSize,
|
BlockchainKernelRequestData.PageSize,
|
||||||
BlockchainKernelRequestData.MaxPages,
|
BlockchainKernelRequestData.MaxPages,
|
||||||
);
|
);
|
||||||
const BlockchainKernelPaginationQuery = await getRepository(
|
const BlockchainKernelPaginationQuery = await getConnection(Global.network).getRepository(
|
||||||
BlockchainKernel,
|
BlockchainKernel,
|
||||||
).find({
|
).find({
|
||||||
skip: PaginationReponseData.startIndex,
|
skip: PaginationReponseData.startIndex,
|
||||||
@ -482,7 +507,25 @@ export class BlockchainKernelController {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
private changeNetwok = async (
|
||||||
|
request: Request,
|
||||||
|
response: Response,
|
||||||
|
next: NextFunction,
|
||||||
|
) => {
|
||||||
|
try {
|
||||||
|
Global.network = request.query.network;
|
||||||
|
console.log(Global.network);
|
||||||
|
//const network = request.query.network;
|
||||||
|
response.status(200).json({
|
||||||
|
status: 200,
|
||||||
|
timestamp: Date.now(),
|
||||||
|
message: 'Network Changed successfully',
|
||||||
|
response: request.query.network,
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
next(new InternalServerErrorException(error));
|
||||||
|
}
|
||||||
|
};
|
||||||
private Translator = async (
|
private Translator = async (
|
||||||
request: Request,
|
request: Request,
|
||||||
response: Response,
|
response: Response,
|
||||||
@ -582,7 +625,7 @@ export class BlockchainKernelController {
|
|||||||
} else {
|
} else {
|
||||||
var timeIntervalQry = "timestamp > current_date - interval '30 days'";
|
var timeIntervalQry = "timestamp > current_date - interval '30 days'";
|
||||||
}
|
}
|
||||||
const TransactionFeeQuery = await getConnection()
|
const TransactionFeeQuery = await getConnection(Global.network)
|
||||||
.query(
|
.query(
|
||||||
"select 1 as hash, date(DATE_TRUNC('day', timestamp)) as date, sum(fee)/1000000 as fee \
|
"select 1 as hash, date(DATE_TRUNC('day', timestamp)) as date, sum(fee)/1000000 as fee \
|
||||||
from blockchain_block t1 join blockchain_kernel t2 on t2.block_id=t1.hash where " +
|
from blockchain_block t1 join blockchain_kernel t2 on t2.block_id=t1.hash where " +
|
||||||
@ -640,7 +683,7 @@ export class BlockchainKernelController {
|
|||||||
// } else {
|
// } else {
|
||||||
// var timeIntervalQry = "timestamp > current_date - interval '30 days'";
|
// var timeIntervalQry = "timestamp > current_date - interval '30 days'";
|
||||||
// }
|
// }
|
||||||
const TransactionHeatmapChartQuery = await getConnection()
|
const TransactionHeatmapChartQuery = await getConnection(Global.network)
|
||||||
.query(
|
.query(
|
||||||
"with hours as ( \
|
"with hours as ( \
|
||||||
SELECT generate_series('" +
|
SELECT generate_series('" +
|
||||||
@ -778,7 +821,7 @@ LEFT JOIN (select block_id, count(block_id) as block_id_count from blockchain_ou
|
|||||||
"blockchain_block.timestamp > current_date - interval '30 days'";
|
"blockchain_block.timestamp > current_date - interval '30 days'";
|
||||||
var seriesquery = "now() - interval '30 days', now()";
|
var seriesquery = "now() - interval '30 days', now()";
|
||||||
}
|
}
|
||||||
const TransactionHeatmapChartQuery = await getConnection()
|
const TransactionHeatmapChartQuery = await getConnection(Global.network)
|
||||||
.query(
|
.query(
|
||||||
'with hours as ( SELECT hour::date from generate_series(' +
|
'with hours as ( SELECT hour::date from generate_series(' +
|
||||||
seriesquery +
|
seriesquery +
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
import express from 'express';
|
import express from 'express';
|
||||||
import { Request, Response, NextFunction } from 'express';
|
import { Request, Response, NextFunction } from 'express';
|
||||||
import { getRepository } from 'typeorm';
|
import { getRepository, getConnection } from 'typeorm';
|
||||||
import { validationMiddleware } from '../middlewares';
|
import { validationMiddleware } from '../middlewares';
|
||||||
|
import { Global } from "../global";
|
||||||
|
|
||||||
import {
|
import {
|
||||||
InternalServerErrorException,
|
InternalServerErrorException,
|
||||||
NoDataFoundException,
|
NoDataFoundException,
|
||||||
@ -210,7 +212,7 @@ export class BlockchainOutputController {
|
|||||||
try {
|
try {
|
||||||
const BlockchainOutputRequestData: BlockchainOutputCreateDto =
|
const BlockchainOutputRequestData: BlockchainOutputCreateDto =
|
||||||
request.body;
|
request.body;
|
||||||
const BlockchainOutputCreateQuery = await getRepository(
|
const BlockchainOutputCreateQuery = await getConnection(Global.network).getRepository(
|
||||||
BlockchainOutput,
|
BlockchainOutput,
|
||||||
).save(BlockchainOutputRequestData);
|
).save(BlockchainOutputRequestData);
|
||||||
response.status(200).json({
|
response.status(200).json({
|
||||||
@ -230,7 +232,7 @@ export class BlockchainOutputController {
|
|||||||
next: NextFunction,
|
next: NextFunction,
|
||||||
) => {
|
) => {
|
||||||
try {
|
try {
|
||||||
const BlockchainOutputFetchQuery = await getRepository(
|
const BlockchainOutputFetchQuery = await getConnection(Global.network).getRepository(
|
||||||
BlockchainOutput,
|
BlockchainOutput,
|
||||||
).findOne({
|
).findOne({
|
||||||
where: { id: request.params.id },
|
where: { id: request.params.id },
|
||||||
@ -256,7 +258,7 @@ export class BlockchainOutputController {
|
|||||||
try {
|
try {
|
||||||
const BlockchainOutputRequestData: BlockchainOutputUpdateDto =
|
const BlockchainOutputRequestData: BlockchainOutputUpdateDto =
|
||||||
request.body;
|
request.body;
|
||||||
const BlockchainOutputUpdateQuery = await getRepository(
|
const BlockchainOutputUpdateQuery = await getConnection(Global.network).getRepository(
|
||||||
BlockchainOutput,
|
BlockchainOutput,
|
||||||
).update(BlockchainOutputRequestData.Id, BlockchainOutputRequestData);
|
).update(BlockchainOutputRequestData.Id, BlockchainOutputRequestData);
|
||||||
response.status(200).json({
|
response.status(200).json({
|
||||||
@ -276,7 +278,7 @@ export class BlockchainOutputController {
|
|||||||
next: NextFunction,
|
next: NextFunction,
|
||||||
) => {
|
) => {
|
||||||
try {
|
try {
|
||||||
const BlockchainOutputDeleteQuery = await getRepository(
|
const BlockchainOutputDeleteQuery = await getConnection(Global.network).getRepository(
|
||||||
BlockchainOutput,
|
BlockchainOutput,
|
||||||
).delete(request.params.Id);
|
).delete(request.params.Id);
|
||||||
BlockchainOutputDeleteQuery
|
BlockchainOutputDeleteQuery
|
||||||
@ -300,7 +302,7 @@ export class BlockchainOutputController {
|
|||||||
try {
|
try {
|
||||||
const BlockchainOutputRequestData: BlockchainOutputPaginationDto =
|
const BlockchainOutputRequestData: BlockchainOutputPaginationDto =
|
||||||
request.query;
|
request.query;
|
||||||
const BlockchainOutputCountQuery = await getRepository(
|
const BlockchainOutputCountQuery = await getConnection(Global.network).getRepository(
|
||||||
BlockchainOutput,
|
BlockchainOutput,
|
||||||
).findAndCount({});
|
).findAndCount({});
|
||||||
if (BlockchainOutputCountQuery[1]) {
|
if (BlockchainOutputCountQuery[1]) {
|
||||||
@ -310,7 +312,7 @@ export class BlockchainOutputController {
|
|||||||
BlockchainOutputRequestData.PageSize,
|
BlockchainOutputRequestData.PageSize,
|
||||||
BlockchainOutputRequestData.MaxPages,
|
BlockchainOutputRequestData.MaxPages,
|
||||||
);
|
);
|
||||||
const BlockchainOutputPaginationQuery = await getRepository(
|
const BlockchainOutputPaginationQuery = await getConnection(Global.network).getRepository(
|
||||||
BlockchainOutput,
|
BlockchainOutput,
|
||||||
).find({
|
).find({
|
||||||
skip: PaginationReponseData.startIndex,
|
skip: PaginationReponseData.startIndex,
|
||||||
|
3
server/global.ts
Normal file
3
server/global.ts
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
export namespace Global {
|
||||||
|
export var network: string = 'Floonet';
|
||||||
|
}
|
@ -3,12 +3,14 @@ import { validate, ValidationError } from 'class-validator';
|
|||||||
import * as express from 'express';
|
import * as express from 'express';
|
||||||
import { NextFunction, Request, Response } from 'express';
|
import { NextFunction, Request, Response } from 'express';
|
||||||
import { HttpException } from '../exceptions/index';
|
import { HttpException } from '../exceptions/index';
|
||||||
|
import { Global } from "../global";
|
||||||
|
|
||||||
export function validationMiddleware<T>(
|
export function validationMiddleware<T>(
|
||||||
type: any,
|
type: any,
|
||||||
skipMissingProperties = false,
|
skipMissingProperties = false,
|
||||||
): express.RequestHandler {
|
): express.RequestHandler {
|
||||||
return (request: Request, response: Response, next: NextFunction) => {
|
return (request: Request, response: Response, next: NextFunction) => {
|
||||||
|
Global.network = request.headers.network;
|
||||||
validate(
|
validate(
|
||||||
plainToClass(type, {
|
plainToClass(type, {
|
||||||
...request.body,
|
...request.body,
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import { getConnection } from "typeorm";
|
import { getConnection } from "typeorm";
|
||||||
|
import { Global } from "../global";
|
||||||
|
|
||||||
var moment = require("moment");
|
var moment = require("moment");
|
||||||
moment.updateLocale('en', {
|
moment.updateLocale('en', {
|
||||||
@ -77,9 +78,9 @@ export async function universalGetLatestBlockDetails(socket) {
|
|||||||
letest_block_num = "",
|
letest_block_num = "",
|
||||||
letest_block_duration = "";
|
letest_block_duration = "";
|
||||||
|
|
||||||
const BlockchainLatestBlockQuery = await getConnection().query(
|
const BlockchainLatestBlockQuery = await getConnection(Global.network).query(
|
||||||
"SELECT bb.timestamp,bb.proof,bb.height,bb.edge_bits,bb.hash,bb.secondary_scaling, bb.previous_id, bb.total_difficulty_cuckaroo, bb.total_difficulty_cuckatoo, bb.total_difficulty_progpow, bb.total_difficulty_randomx, COUNT(DISTINCT(bi.block_id)) AS input_count, COUNT(DISTINCT(bk.block_id)) AS kernel_count, COUNT(DISTINCT(bo.block_id)) AS output_count FROM blockchain_block bb LEFT JOIN blockchain_input bi ON bi.block_id = bb.hash LEFT JOIN blockchain_kernel bk ON bk.block_id = bb.hash LEFT JOIN blockchain_output bo ON bo.block_id = bb.hash group by bb.hash, bb.timestamp ORDER BY bb.timestamp DESC LIMIT 1");
|
"SELECT bb.timestamp,bb.proof,bb.height,bb.edge_bits,bb.hash,bb.secondary_scaling, bb.previous_id, bb.total_difficulty_cuckaroo, bb.total_difficulty_cuckatoo, bb.total_difficulty_progpow, bb.total_difficulty_randomx, COUNT(DISTINCT(bi.block_id)) AS input_count, COUNT(DISTINCT(bk.block_id)) AS kernel_count, COUNT(DISTINCT(bo.block_id)) AS output_count FROM blockchain_block bb LEFT JOIN blockchain_input bi ON bi.block_id = bb.hash LEFT JOIN blockchain_kernel bk ON bk.block_id = bb.hash LEFT JOIN blockchain_output bo ON bo.block_id = bb.hash group by bb.hash, bb.timestamp ORDER BY bb.timestamp DESC LIMIT 1");
|
||||||
const BlockchainPreviousBlockQuery = await getConnection().query(
|
const BlockchainPreviousBlockQuery = await getConnection(Global.network).query(
|
||||||
"SELECT total_difficulty_cuckaroo, total_difficulty_cuckatoo, total_difficulty_progpow, total_difficulty_randomx FROM blockchain_block WHERE hash=" +
|
"SELECT total_difficulty_cuckaroo, total_difficulty_cuckatoo, total_difficulty_progpow, total_difficulty_randomx FROM blockchain_block WHERE hash=" +
|
||||||
"'" +
|
"'" +
|
||||||
BlockchainLatestBlockQuery[0].previous_id +
|
BlockchainLatestBlockQuery[0].previous_id +
|
||||||
|
@ -1,8 +1,38 @@
|
|||||||
<header class="headerbg">
|
<header class="headerbg">
|
||||||
|
<div class="home_tst_net mt-3 d-block d-sm-none">
|
||||||
|
<a href="https://epic.tech/" target="_blank" class="text_underline mr-2">Epic Cash</a>
|
||||||
|
<span>You are viewing </span>
|
||||||
|
<select (change)="onChangeNetwork($event.target.value)">
|
||||||
|
<option value="Floonet" [selected]="'Floonet' == getNetwork()" >FlooNet</option>
|
||||||
|
<option value="Testnet" [selected]="'Testnet' == getNetwork()">TestNet</option>
|
||||||
|
<option disabled value="Mainnet">MainNet</option>
|
||||||
|
</select>
|
||||||
|
<!-- <ul class="list-unstyled d-inline-block mb-0">
|
||||||
|
<li class="nav-item dropdown">
|
||||||
|
<a
|
||||||
|
class="nav-link dropdown-toggle bg-white"
|
||||||
|
id="navbarDropdown"
|
||||||
|
role="button"
|
||||||
|
data-toggle="dropdown"
|
||||||
|
aria-haspopup="true"
|
||||||
|
aria-expanded="false"
|
||||||
|
>
|
||||||
|
TestNet
|
||||||
|
</a>
|
||||||
|
<div class="dropdown-menu net_dropdwn" aria-labelledby="navbarDropdown">
|
||||||
|
<a class="dropdown-item p-2 disabled" style="background-color: #00000024;" target = '_blank' href="#">MainNet</a
|
||||||
|
>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</li>
|
||||||
|
</ul> -->
|
||||||
|
|
||||||
|
</div>
|
||||||
<nav class="navbar navbar-expand navbar-light bg-transparent">
|
<nav class="navbar navbar-expand navbar-light bg-transparent">
|
||||||
<div class="container-fluid">
|
<div class="container-fluid">
|
||||||
<div class="collapse navbar-collapse home_mble_hdr" id="navbarSupportedContent">
|
<div class="collapse navbar-collapse home_mble_hdr" id="navbarSupportedContent">
|
||||||
|
|
||||||
|
|
||||||
<ul class="navbar-nav ml-auto">
|
<ul class="navbar-nav ml-auto">
|
||||||
<!-- <li *ngIf="TimeArr" class="d-none d-sm-inline-block"><h1 class="test_msg d-inline-block mb-0 align-middle mr-3">{{'home.HEADER_TEXT' | translate}}</h1>
|
<!-- <li *ngIf="TimeArr" class="d-none d-sm-inline-block"><h1 class="test_msg d-inline-block mb-0 align-middle mr-3">{{'home.HEADER_TEXT' | translate}}</h1>
|
||||||
<h1 class="test_msg align-middle mr-3 d-inline-block mb-0">{{'home.COUNTDOWN' | translate}}</h1>
|
<h1 class="test_msg align-middle mr-3 d-inline-block mb-0">{{'home.COUNTDOWN' | translate}}</h1>
|
||||||
@ -14,10 +44,16 @@
|
|||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
</li> -->
|
</li> -->
|
||||||
<li class="home_tst_net mr-3">
|
<li class="home_tst_net mr-3 d-none d-sm-inline-block">
|
||||||
<a href="https://epic.tech/" target="_blank" class="text_underline mr-2">Epic Cash</a>
|
<a href="https://epic.tech/" target="_blank" class="text_underline mr-2">Epic Cash</a>
|
||||||
<span>You are viewing </span>
|
<span>You are viewing </span>
|
||||||
<ul class="list-unstyled d-inline-block mb-0">
|
<select (change)="onChangeNetwork($event.target.value)">
|
||||||
|
<option value="Floonet" [selected]="'Floonet' == getNetwork()" >FlooNet</option>
|
||||||
|
<option value="Testnet" [selected]="'Testnet' == getNetwork()">TestNet</option>
|
||||||
|
<option disabled value="Mainnet">MainNet</option>
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<!-- <ul class="list-unstyled d-inline-block mb-0">
|
||||||
<li class="nav-item dropdown">
|
<li class="nav-item dropdown">
|
||||||
<a
|
<a
|
||||||
class="nav-link dropdown-toggle bg-white"
|
class="nav-link dropdown-toggle bg-white"
|
||||||
@ -36,7 +72,7 @@
|
|||||||
>
|
>
|
||||||
</div>
|
</div>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul> -->
|
||||||
|
|
||||||
</li>
|
</li>
|
||||||
<li class="nav-item px-2 dropdown bg-white">
|
<li class="nav-item px-2 dropdown bg-white">
|
||||||
|
@ -2,6 +2,7 @@ import { Component, OnInit, Inject } from '@angular/core';
|
|||||||
import { DOCUMENT } from '@angular/common';
|
import { DOCUMENT } from '@angular/common';
|
||||||
import { ChartService } from '../../services/chart.service';
|
import { ChartService } from '../../services/chart.service';
|
||||||
import { TransServiceService } from '../../services/trans-service.service';
|
import { TransServiceService } from '../../services/trans-service.service';
|
||||||
|
import { HttpParams } from '@angular/common/http';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'epic-explorer-header',
|
selector: 'epic-explorer-header',
|
||||||
@ -25,6 +26,15 @@ export class HeaderComponent implements OnInit {
|
|||||||
}, 1000);
|
}, 1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public getNetwork(){
|
||||||
|
return localStorage.getItem('network');
|
||||||
|
}
|
||||||
|
|
||||||
|
public onChangeNetwork(networkValue){
|
||||||
|
localStorage.setItem('network', networkValue);
|
||||||
|
window.location.reload();
|
||||||
|
}
|
||||||
|
|
||||||
public ChangeTheme() {
|
public ChangeTheme() {
|
||||||
this.document.body.classList.toggle('dark_theme');
|
this.document.body.classList.toggle('dark_theme');
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,12 @@
|
|||||||
<a class="chart_heading d-sm-none" routerLink="/"><span class="txt_primary">Epic</span><span>Explorer</span></a>
|
<a class="chart_heading d-sm-none" routerLink="/"><span class="txt_primary">Epic</span><span>Explorer</span></a>
|
||||||
<div class=" d-none d-sm-inline-block mr-3">
|
<div class=" d-none d-sm-inline-block mr-3">
|
||||||
<span>You are viewing </span>
|
<span>You are viewing </span>
|
||||||
<ul class="list-unstyled d-inline-block">
|
<select (change)="onChangeNetwork($event.target.value)">
|
||||||
|
<option value="Floonet" [selected]="'Floonet' == getNetwork()" >FlooNet</option>
|
||||||
|
<option value="Testnet" [selected]="'Testnet' == getNetwork()">TestNet</option>
|
||||||
|
<option disabled value="Mainnet">MainNet</option>
|
||||||
|
</select>
|
||||||
|
<!-- <ul class="list-unstyled d-inline-block">
|
||||||
<li class="nav-item dropdown">
|
<li class="nav-item dropdown">
|
||||||
|
|
||||||
<a class="nav-link dropdown-toggle bg-white" href="#" id="navbarDropdown" role="button"
|
<a class="nav-link dropdown-toggle bg-white" href="#" id="navbarDropdown" role="button"
|
||||||
@ -21,8 +26,8 @@
|
|||||||
<a class="dropdown-item p-2 disabled" href="#">MainNet</a>
|
<a class="dropdown-item p-2 disabled" href="#">MainNet</a>
|
||||||
</div>
|
</div>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul> -->
|
||||||
<span> Network </span>
|
<!-- <span> Network </span> -->
|
||||||
</div>
|
</div>
|
||||||
<div class="position-relative d-none d-sm-inline-block">
|
<div class="position-relative d-none d-sm-inline-block">
|
||||||
<input type="text" [(ngModel)]="search" #ctrl="ngModel" class="form-control search_input"
|
<input type="text" [(ngModel)]="search" #ctrl="ngModel" class="form-control search_input"
|
||||||
@ -61,7 +66,12 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="d-block d-sm-none text-center mt-3 mx-auto">
|
<div class="d-block d-sm-none text-center mt-3 mx-auto">
|
||||||
<span>You are viewing </span>
|
<span>You are viewing </span>
|
||||||
<ul class="list-unstyled d-inline-block">
|
<select (change)="onChangeNetwork($event.target.value)">
|
||||||
|
<option value="Floonet" [selected]="'Floonet' == getNetwork()" >FlooNet</option>
|
||||||
|
<option value="Testnet" [selected]="'Testnet' == getNetwork()">TestNet</option>
|
||||||
|
<option disabled value="Mainnet">MainNet</option>
|
||||||
|
</select>
|
||||||
|
<!-- <ul class="list-unstyled d-inline-block">
|
||||||
<li class="nav-item dropdown">
|
<li class="nav-item dropdown">
|
||||||
|
|
||||||
<a class="nav-link dropdown-toggle bg-white" href="#" id="navbarDropdown" role="button"
|
<a class="nav-link dropdown-toggle bg-white" href="#" id="navbarDropdown" role="button"
|
||||||
@ -74,8 +84,8 @@
|
|||||||
<a class="dropdown-item p-2 disabled" href="#">MainNet</a>
|
<a class="dropdown-item p-2 disabled" href="#">MainNet</a>
|
||||||
</div>
|
</div>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul> -->
|
||||||
<span> Network </span>
|
<!-- <span> Network </span> -->
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</nav>
|
</nav>
|
||||||
|
@ -23,6 +23,16 @@ export class SiteheaderComponent implements OnInit {
|
|||||||
this.document.body.classList.toggle('dark_theme');
|
this.document.body.classList.toggle('dark_theme');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public getNetwork(){
|
||||||
|
return localStorage.getItem('network');
|
||||||
|
}
|
||||||
|
|
||||||
|
public onChangeNetwork(networkValue){
|
||||||
|
localStorage.setItem('network', networkValue);
|
||||||
|
window.location.reload();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
onSearch(hash) {
|
onSearch(hash) {
|
||||||
this.router.navigate(['blockdetail', hash]);
|
this.router.navigate(['blockdetail', hash]);
|
||||||
}
|
}
|
||||||
|
@ -31,7 +31,8 @@ export class ChartService {
|
|||||||
public apiGetRequest(request: any, reqUrl): Observable<any> {
|
public apiGetRequest(request: any, reqUrl): Observable<any> {
|
||||||
return this.http
|
return this.http
|
||||||
.get(`${environment.apiUrl}` + reqUrl, {
|
.get(`${environment.apiUrl}` + reqUrl, {
|
||||||
params: request
|
params: request,
|
||||||
|
headers: this.getHttpheader()
|
||||||
})
|
})
|
||||||
.pipe(
|
.pipe(
|
||||||
map(res => {
|
map(res => {
|
||||||
@ -41,6 +42,17 @@ export class ChartService {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public getHttpheader(){
|
||||||
|
var network;
|
||||||
|
if(localStorage.getItem('network') == null){
|
||||||
|
network = "Floonet"
|
||||||
|
}else{
|
||||||
|
network = localStorage.getItem('network')
|
||||||
|
}
|
||||||
|
return new HttpHeaders().set('network', network);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public getLatestblockdetails() {
|
public getLatestblockdetails() {
|
||||||
return Observable.create(observer => {
|
return Observable.create(observer => {
|
||||||
this.socket.on("latestblockdetail", response => {
|
this.socket.on("latestblockdetail", response => {
|
||||||
|
@ -76,6 +76,9 @@
|
|||||||
.theme_switch{padding-top: 8px; padding-bottom: 8px;}
|
.theme_switch{padding-top: 8px; padding-bottom: 8px;}
|
||||||
.theme_switch img{height: 15px;}
|
.theme_switch img{height: 15px;}
|
||||||
.peer_table_data .col-6 {flex: 0 0 100%; max-width: 100%; }
|
.peer_table_data .col-6 {flex: 0 0 100%; max-width: 100%; }
|
||||||
|
/* .home_mble_hdr .navbar-nav{margin: 15px auto 0; width: 100%;} */
|
||||||
|
.home_tst_net{font-size: 15px; text-align: center;}
|
||||||
|
.navbar-nav{justify-content: center;}
|
||||||
}
|
}
|
||||||
@media(max-width: 588px){
|
@media(max-width: 588px){
|
||||||
/* .view_page_header{text-align: center;} */
|
/* .view_page_header{text-align: center;} */
|
||||||
@ -85,8 +88,7 @@
|
|||||||
}
|
}
|
||||||
@media(max-width: 470px){
|
@media(max-width: 470px){
|
||||||
.navbar-expand .navbar-collapse.home_mble_hdr{display: block !important;}
|
.navbar-expand .navbar-collapse.home_mble_hdr{display: block !important;}
|
||||||
.home_mble_hdr .navbar-nav{margin: 15px auto 0; width: 63%;}
|
|
||||||
.home_tst_net{font-size: 15px; width: 85%; margin: 0 auto;}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@media(max-width: 365px){
|
@media(max-width: 365px){
|
||||||
|
Loading…
Reference in New Issue
Block a user