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

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;