socket fixed
This commit is contained in:
parent
118f8dd5c6
commit
a444afc0b5
@ -182,15 +182,15 @@ console.log(__dirname);
|
||||
BlockchainOutput],
|
||||
}]).then(async () => {
|
||||
|
||||
var connection_test = await getConnection("Testnet");
|
||||
const server = app.listen(PORT, () => {
|
||||
console.log(`Node Express server listening on http://localhost:${PORT}`);
|
||||
});
|
||||
const io = require("socket.io").listen(server);
|
||||
io.sockets.on("connection", socket => {
|
||||
//setTimeout(function() {
|
||||
universalGetLatestBlockDetails(socket, connection_test);
|
||||
universalGetLatestBlockDetails(socket);
|
||||
//},1000);
|
||||
socket.on("disconnect", () => console.log("Client disconnected"));
|
||||
});
|
||||
})
|
||||
.catch(error => {
|
||||
|
@ -1,5 +1,6 @@
|
||||
import { getConnection } from "typeorm";
|
||||
import { Global } from "../global";
|
||||
import {createConnection, Connection} from "typeorm";
|
||||
|
||||
var moment = require("moment");
|
||||
moment.updateLocale('en', {
|
||||
@ -70,7 +71,7 @@ function convertMinsToHrmin(millseconds, insec) {
|
||||
}
|
||||
|
||||
|
||||
export async function universalGetLatestBlockDetails(socket, connection_test) {
|
||||
export async function universalGetLatestBlockDetails(socket) {
|
||||
|
||||
|
||||
let block_height = "",
|
||||
@ -78,14 +79,28 @@ export async function universalGetLatestBlockDetails(socket, connection_test) {
|
||||
letest_block_num = "",
|
||||
letest_block_duration = "";
|
||||
|
||||
const BlockchainLatestBlockQuery = await connection_test.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");
|
||||
const BlockchainPreviousBlockQuery = await connection_test.query(
|
||||
|
||||
// const BlockchainLatestBlockQuery = await getConnection("Testnet").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");
|
||||
// const BlockchainPreviousBlockQuery = await getConnection("Testnet").query(
|
||||
// "SELECT total_difficulty_cuckaroo, total_difficulty_cuckatoo, total_difficulty_progpow, total_difficulty_randomx FROM blockchain_block WHERE hash=" +
|
||||
// "'" +
|
||||
// BlockchainLatestBlockQuery[0].previous_id +
|
||||
// "'"
|
||||
// );
|
||||
|
||||
getConnection("Testnet").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").then(res => {
|
||||
var BlockchainLatestBlockQuery = res;
|
||||
//console.log(res);
|
||||
getConnection("Testnet").query(
|
||||
"SELECT total_difficulty_cuckaroo, total_difficulty_cuckatoo, total_difficulty_progpow, total_difficulty_randomx FROM blockchain_block WHERE hash=" +
|
||||
"'" +
|
||||
BlockchainLatestBlockQuery[0].previous_id +
|
||||
"'"
|
||||
);
|
||||
).then( res2 => {
|
||||
var BlockchainPreviousBlockQuery = res2;
|
||||
//console.log(BlockchainPreviousBlockQuery);
|
||||
let height = BlockchainLatestBlockQuery[0].height;
|
||||
|
||||
// if (height > 12960) {
|
||||
@ -296,6 +311,12 @@ export async function universalGetLatestBlockDetails(socket, connection_test) {
|
||||
BlockchainLatestBlockQuery[0].total_difficulty_randomx
|
||||
});
|
||||
setTimeout(function() {
|
||||
universalGetLatestBlockDetails(socket, connection_test);
|
||||
universalGetLatestBlockDetails(socket);
|
||||
},1000);
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user