fix(batch-mining): 修正阶段划分逻辑
- preMineDays 是该批次加入后挖矿的天数,不是差值 - 批次1的preMineDays=3 → 批次1先独挖3天 - 批次2的preMineDays=2 → 批次1+2一起挖2天 - 批次3的preMineDays=1 → 批次1+2+3一起挖1天 - 最后所有批次一起挖剩余天数 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
8b8d1f7d16
commit
702fa937e8
|
|
@ -307,14 +307,16 @@ export class BatchMiningService {
|
|||
* 根据批次的"提前天数"构建各挖矿阶段:
|
||||
* - preMineDays 表示该批次比下一批次提前开始的天数
|
||||
* - 批次1的 preMineDays=3 意味着批次1比批次2提前3天
|
||||
* - 批次2的 preMineDays=2 意味着批次2比批次3提前2天
|
||||
* - 批次3的 preMineDays=1 意味着批次3比批次4提前1天
|
||||
* - 批次1的 preMineDays=3 意味着批次1先独挖3天
|
||||
* - 批次2的 preMineDays=2 意味着批次1+2一起挖2天
|
||||
* - 批次3的 preMineDays=1 意味着批次1+2+3一起挖1天
|
||||
*
|
||||
* 阶段划分:
|
||||
* - 阶段1: 只有批次1,持续 (批次1的preMineDays - 批次2的preMineDays) 天
|
||||
* - 阶段2: 批次1+2,持续 (批次2的preMineDays - 批次3的preMineDays) 天
|
||||
* - 阶段1: 只有批次1,持续 preMineDays 天
|
||||
* - 阶段2: 批次1+2,持续 preMineDays 天
|
||||
* - 阶段3: 批次1+2+3,持续 preMineDays 天
|
||||
* - ...
|
||||
* - 最后阶段: 所有批次一起挖 (totalMiningDays - 提前天数的总和)
|
||||
* - 最后阶段: 所有批次一起挖 (totalMiningDays - 所有提前天数之和)
|
||||
*/
|
||||
private buildMiningPhases(
|
||||
items: BatchMiningItem[],
|
||||
|
|
@ -343,8 +345,6 @@ export class BatchMiningService {
|
|||
this.logger.log(`[buildMiningPhases] 各批次提前天数: ${JSON.stringify(Object.fromEntries(batchPreMineDays))}`);
|
||||
this.logger.log(`[buildMiningPhases] 最大总挖矿天数: ${maxTotalMiningDays}`);
|
||||
|
||||
// 获取第一批次的提前天数
|
||||
const firstBatchPreMineDays = batchPreMineDays.get(sortedBatches[0]) || 0;
|
||||
if (maxTotalMiningDays <= 0) {
|
||||
this.logger.warn('[buildMiningPhases] 总挖矿天数<=0,无法计算');
|
||||
return phases;
|
||||
|
|
@ -355,17 +355,16 @@ export class BatchMiningService {
|
|||
let usedDays = 0; // 已分配的天数
|
||||
|
||||
// 按批次顺序添加阶段(提前挖矿阶段)
|
||||
// 每个批次加入后,挖该批次的 preMineDays 天
|
||||
for (let i = 0; i < sortedBatches.length; i++) {
|
||||
const currentBatch = sortedBatches[i];
|
||||
const currentPreMineDays = batchPreMineDays.get(currentBatch) || 0;
|
||||
const nextBatch = sortedBatches[i + 1];
|
||||
const nextPreMineDays = nextBatch !== undefined ? (batchPreMineDays.get(nextBatch) || 0) : 0;
|
||||
|
||||
// 当前批次加入挖矿
|
||||
participatingBatches.push(currentBatch);
|
||||
|
||||
// 计算当前阶段持续的天数 = 当前批次提前天数 - 下一批次提前天数
|
||||
const phaseDays = currentPreMineDays - nextPreMineDays;
|
||||
// 该阶段持续天数 = 当前批次的提前天数
|
||||
const phaseDays = currentPreMineDays;
|
||||
|
||||
if (phaseDays > 0) {
|
||||
// 计算该阶段参与用户的算力
|
||||
|
|
|
|||
Loading…
Reference in New Issue