some bugs fixed, add alph node method
This commit is contained in:
parent
2d8675368f
commit
9fe4d9145a
5
README
5
README
|
@ -199,4 +199,7 @@ pm2 start app.js --name enx-hashrate -- hashrate enx
|
||||||
pm2 start app.js --name enx-report -- report enx
|
pm2 start app.js --name enx-report -- report enx
|
||||||
|
|
||||||
pm2 start app.js --name alph-report -- report alph
|
pm2 start app.js --name alph-report -- report alph
|
||||||
pm2 start app.js --name alph-hashrate -- hashrate alph
|
pm2 start app.js --name alph-hashrate -- hashrate alph
|
||||||
|
pm2 start app.js --name alph-confirm -- confirm alph
|
||||||
|
pm2 start app.js --name alph-distribution -- distribution alph
|
||||||
|
pm2 start app.js --name alph-balance -- balance alph
|
2
app.js
2
app.js
|
@ -128,7 +128,7 @@ if (method === "balance") {
|
||||||
}
|
}
|
||||||
|
|
||||||
let hour = 4
|
let hour = 4
|
||||||
if(coin === "rxd"){
|
if(coin === "rxd" || coin === "alph"){
|
||||||
hour = 9
|
hour = 9
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
10
lib/node.js
10
lib/node.js
|
@ -481,12 +481,18 @@ class ALPHRPCNode extends HttpNode {
|
||||||
const coinbaseTx = transactions[transactions.length - 1].unsigned
|
const coinbaseTx = transactions[transactions.length - 1].unsigned
|
||||||
if (coinbaseTx.inputs.length === 0) {
|
if (coinbaseTx.inputs.length === 0) {
|
||||||
const {fixedOutputs} = coinbaseTx
|
const {fixedOutputs} = coinbaseTx
|
||||||
if(fixedOutputs.length === 1){
|
for(let item of fixedOutputs){
|
||||||
const {attoAlphAmount, address } = fixedOutputs[0]
|
const {attoAlphAmount, address } = item
|
||||||
if(address === REPORT_ADDRESS){
|
if(address === REPORT_ADDRESS){
|
||||||
return {height, hash: block_hash, time:Math.trunc(timestamp / 1000), block_reward: Number(attoAlphAmount), block_fees: null };
|
return {height, hash: block_hash, time:Math.trunc(timestamp / 1000), block_reward: Number(attoAlphAmount), block_fees: null };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// if(fixedOutputs.length === 1){
|
||||||
|
// const {attoAlphAmount, address } = fixedOutputs[0]
|
||||||
|
// if(address === REPORT_ADDRESS){
|
||||||
|
// return {height, hash: block_hash, time:Math.trunc(timestamp / 1000), block_reward: Number(attoAlphAmount), block_fees: null };
|
||||||
|
// }
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
} catch(err){
|
} catch(err){
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
const Init = require("./init");
|
const Init = require("./init");
|
||||||
|
const Times = require("../public/times");
|
||||||
|
|
||||||
class Confirm extends Init {
|
class Confirm extends Init {
|
||||||
constructor(coin) {
|
constructor(coin) {
|
||||||
|
@ -28,13 +29,27 @@ class Confirm extends Init {
|
||||||
// 查询当前最高成熟高度,即当前最新高度 - MAX_MATURE
|
// 查询当前最高成熟高度,即当前最新高度 - MAX_MATURE
|
||||||
async query_maxture_height() {
|
async query_maxture_height() {
|
||||||
try {
|
try {
|
||||||
const now_height = await this.node.getblockcount();
|
if(this.coin !== "alph"){
|
||||||
const max_height = Number(now_height) - this.MAX_MATURE;
|
const now_height = await this.node.getblockcount();
|
||||||
if (!this.isPositiveInteger(max_height)) {
|
const max_height = Number(now_height) - this.MAX_MATURE;
|
||||||
console.log(`当前节点最大高度为${now_height}, 当前成熟高度为${max_height}`);
|
if (!this.isPositiveInteger(max_height)) {
|
||||||
return false;
|
console.log(`当前节点最大高度为${now_height}, 当前成熟高度为${max_height}`);
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
return max_height;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
return max_height;
|
const now = Date.now().valueOf()
|
||||||
|
const max_mature_time = now - this.MAX_MATURE * 60 * 1000
|
||||||
|
const ymd = Times.utcTime(max_mature_time)
|
||||||
|
const sql = `SELECT MAX(height) AS max_height FROM alph_blkreportprofitv2 WHERE date <= ? AND state = ?;`
|
||||||
|
const data = await this.distribution.exec(sql, [ymd, 0])
|
||||||
|
if(!data[0]){
|
||||||
|
console.log(`alph当前时间没有需要更新的成熟区块`);
|
||||||
|
return false
|
||||||
|
} else {
|
||||||
|
return data[0].max_height
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
throw err;
|
throw err;
|
||||||
|
|
Loading…
Reference in New Issue