some bugs fixed, add alph node method

This commit is contained in:
lzx 2025-04-11 19:59:58 +08:00
parent 2d8675368f
commit 9fe4d9145a
4 changed files with 34 additions and 10 deletions

5
README
View File

@ -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 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
View File

@ -128,7 +128,7 @@ if (method === "balance") {
}
let hour = 4
if(coin === "rxd"){
if(coin === "rxd" || coin === "alph"){
hour = 9
}

View File

@ -481,12 +481,18 @@ class ALPHRPCNode extends HttpNode {
const coinbaseTx = transactions[transactions.length - 1].unsigned
if (coinbaseTx.inputs.length === 0) {
const {fixedOutputs} = coinbaseTx
if(fixedOutputs.length === 1){
const {attoAlphAmount, address } = fixedOutputs[0]
for(let item of fixedOutputs){
const {attoAlphAmount, address } = item
if(address === REPORT_ADDRESS){
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
} catch(err){

View File

@ -1,4 +1,5 @@
const Init = require("./init");
const Times = require("../public/times");
class Confirm extends Init {
constructor(coin) {
@ -28,13 +29,27 @@ class Confirm extends Init {
// 查询当前最高成熟高度,即当前最新高度 - MAX_MATURE
async query_maxture_height() {
try {
const now_height = await this.node.getblockcount();
const max_height = Number(now_height) - this.MAX_MATURE;
if (!this.isPositiveInteger(max_height)) {
console.log(`当前节点最大高度为${now_height}, 当前成熟高度为${max_height}`);
return false;
if(this.coin !== "alph"){
const now_height = await this.node.getblockcount();
const max_height = Number(now_height) - this.MAX_MATURE;
if (!this.isPositiveInteger(max_height)) {
console.log(`当前节点最大高度为${now_height}, 当前成熟高度为${max_height}`);
return false;
} else {
return max_height;
}
} 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) {
throw err;