fix(batch-mining): 添加详细日志追踪阶段划分和总天数计算
- 添加更清晰的阶段划分注释说明 - 添加日志打印最后批次preMineDays=0时改为1天的情况 - 添加预期总金额日志用于验证计算正确性 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
0adc4c8c26
commit
d47276a460
|
|
@ -388,26 +388,35 @@ export class BatchMiningService {
|
|||
let participatingBatches: number[] = [];
|
||||
let totalDays = 0;
|
||||
|
||||
// 按批次顺序添加阶段
|
||||
// 阶段1: 只有第一批,分配第一批的 preMineDays 天
|
||||
// 阶段2: 第一批+第二批,分配第二批的 preMineDays 天
|
||||
// 阶段3: 第一批+第二批+第三批,分配第三批的 preMineDays 天
|
||||
// ...依次类推
|
||||
// 最后一个批次即使 preMineDays=0,也要算1天(所有人一起挖1天)
|
||||
// 正确的阶段划分逻辑:
|
||||
// - 阶段N的天数 = 批次N的 preMineDays(表示批次N比批次N+1提前的天数)
|
||||
// - 阶段N的参与者 = 批次1到批次N(即在批次N+1加入之前,批次1-N一起挖)
|
||||
//
|
||||
// 示例(13个批次,preMineDays分别为 8,7,6,6,6,6,6,6,6,6,6,6,0):
|
||||
// - 阶段1: 只有批次1,挖8天(批次1比批次2提前8天)
|
||||
// - 阶段2: 批次1+2,挖7天(批次2比批次3提前7天)
|
||||
// - ...
|
||||
// - 阶段12: 批次1-12,挖6天(批次12比批次13提前6天)
|
||||
// - 阶段13: 批次1-13,挖1天(最后批次preMineDays=0时算1天)
|
||||
//
|
||||
// 总天数 = 8+7+6×10+1 = 76天(如果最后批次preMineDays=0)
|
||||
// 或者如果Excel中preMineDays总和就是75,则不需要额外加1
|
||||
|
||||
for (let i = 0; i < sortedBatches.length; i++) {
|
||||
const currentBatch = sortedBatches[i];
|
||||
let currentPreMineDays = batchPreMineDays.get(currentBatch) || 0;
|
||||
const isLastBatch = i === sortedBatches.length - 1;
|
||||
|
||||
// 当前批次加入参与列表
|
||||
// 当前批次加入参与列表(在计算阶段之前加入)
|
||||
participatingBatches.push(currentBatch);
|
||||
|
||||
// 最后一个批次如果 preMineDays=0,改为1天
|
||||
const isLastBatch = i === sortedBatches.length - 1;
|
||||
// 最后一个批次如果 preMineDays=0,改为1天(所有批次至少要一起挖1天)
|
||||
if (isLastBatch && currentPreMineDays === 0) {
|
||||
currentPreMineDays = 1;
|
||||
this.logger.log(`[buildMiningPhases] 最后批次${currentBatch}的preMineDays=0,改为1天`);
|
||||
}
|
||||
|
||||
// 该阶段持续天数 = 当前批次的 preMineDays
|
||||
// 只有当该阶段有天数时才创建阶段
|
||||
if (currentPreMineDays > 0) {
|
||||
// 计算该阶段参与用户的总算力
|
||||
let participatingContribution = new Decimal(0);
|
||||
|
|
@ -430,7 +439,13 @@ export class BatchMiningService {
|
|||
}
|
||||
}
|
||||
|
||||
this.logger.log(`[buildMiningPhases] 总天数: ${totalDays}`);
|
||||
// 计算预期的每日补发额度(用于验证)
|
||||
// 每日产出 = 1000000 / (365 * 2) = 1369.863014
|
||||
// 用户分到的70% = 958.9041096 per day
|
||||
const expectedDailyAllocation = new Decimal('958.904109589041');
|
||||
const expectedTotal = expectedDailyAllocation.times(totalDays);
|
||||
this.logger.log(`[buildMiningPhases] 总天数: ${totalDays}, 预期总金额: ${expectedTotal.toFixed(2)} (${totalDays}天 × 958.904/天)`);
|
||||
|
||||
return phases;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue