From e79d42db61dcfccf7e8b9c28e30a167211eb908d Mon Sep 17 00:00:00 2001 From: hailin Date: Wed, 21 Jan 2026 20:58:42 -0800 Subject: [PATCH] =?UTF-8?q?fix(batch-mining):=20=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=E8=AE=A1=E7=AE=97=E9=80=BB=E8=BE=91=EF=BC=8C=E6=89=B9=E9=87=8F?= =?UTF-8?q?=E8=A1=A5=E5=8F=91=E7=94=A8=E6=88=B7=E5=8F=AA=E5=8D=A0=E5=85=A8?= =?UTF-8?q?=E7=BD=9170%?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 添加 BATCH_USERS_NETWORK_RATIO 常量(0.70) - 计算全网算力时:实际全网算力 = 用户算力 / 0.7 - 修正预期结果约为 70,958 而非 104,656 Co-Authored-By: Claude Opus 4.5 --- .../services/batch-mining.service.ts | 28 +++++++++++++------ 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/backend/services/mining-service/src/application/services/batch-mining.service.ts b/backend/services/mining-service/src/application/services/batch-mining.service.ts index 483301c0..8cfcd61e 100644 --- a/backend/services/mining-service/src/application/services/batch-mining.service.ts +++ b/backend/services/mining-service/src/application/services/batch-mining.service.ts @@ -90,6 +90,8 @@ export interface BatchMiningPreviewResult { const BASE_CONTRIBUTION_PER_TREE = new Decimal('22617'); // 每棵树的基础算力 const PERSONAL_RATE = new Decimal('0.70'); // 个人算力占比 70% const SECONDS_PER_DAY = 86400; +// 批量补发用户占全网算力的比例(这些用户只占全网的70%,还有30%是其他用户) +const BATCH_USERS_NETWORK_RATIO = new Decimal('0.70'); /** * 挖矿阶段信息 @@ -235,10 +237,13 @@ export class BatchMiningService { const batchResults: BatchMiningPreviewResult['batches'] = []; // 计算累计全网算力(最终状态) - let finalNetworkContribution = new Decimal(0); + // 这些用户只占全网的70%,所以全网算力 = 用户算力 / 0.7 + let totalUserContribution = new Decimal(0); for (const contribution of batchContributions.values()) { - finalNetworkContribution = finalNetworkContribution.plus(contribution); + totalUserContribution = totalUserContribution.plus(contribution); } + const finalNetworkContribution = totalUserContribution.dividedBy(BATCH_USERS_NETWORK_RATIO); + this.logger.log(`[preview] 用户总算力: ${totalUserContribution.toFixed(2)}, 全网算力(70%): ${finalNetworkContribution.toFixed(2)}`); for (const batchNum of sortedBatches) { const batchItems = batchGroups.get(batchNum)!; @@ -364,11 +369,14 @@ export class BatchMiningService { const phaseDays = currentPreMineDays - nextPreMineDays; if (phaseDays > 0) { - // 计算该阶段的全网算力 - let networkContribution = new Decimal(0); + // 计算该阶段参与用户的算力 + let participatingContribution = new Decimal(0); for (const batch of participatingBatches) { - networkContribution = networkContribution.plus(batchContributions.get(batch) || 0); + participatingContribution = participatingContribution.plus(batchContributions.get(batch) || 0); } + // 实际全网算力 = 参与用户算力 / 用户占比 + // 因为这些用户只占全网的70%,所以全网算力 = 用户算力 / 0.7 + const networkContribution = participatingContribution.dividedBy(BATCH_USERS_NETWORK_RATIO); phases.push({ phaseNumber: currentPhase, @@ -379,7 +387,7 @@ export class BatchMiningService { participatingBatches: [...participatingBatches], }); - this.logger.log(`[buildMiningPhases] 阶段${currentPhase}: ${phaseDays}天, 批次[${participatingBatches.join(',')}], 算力=${networkContribution.toFixed(2)}`); + this.logger.log(`[buildMiningPhases] 阶段${currentPhase}: ${phaseDays}天, 批次[${participatingBatches.join(',')}], 参与算力=${participatingContribution.toFixed(2)}, 全网算力=${networkContribution.toFixed(2)}`); currentPhase++; usedDays += phaseDays; } @@ -389,10 +397,12 @@ export class BatchMiningService { const remainingDays = maxTotalMiningDays - usedDays; if (remainingDays > 0) { // 所有批次都参与 - let networkContribution = new Decimal(0); + let participatingContribution = new Decimal(0); for (const batch of sortedBatches) { - networkContribution = networkContribution.plus(batchContributions.get(batch) || 0); + participatingContribution = participatingContribution.plus(batchContributions.get(batch) || 0); } + // 实际全网算力 = 参与用户算力 / 用户占比 + const networkContribution = participatingContribution.dividedBy(BATCH_USERS_NETWORK_RATIO); phases.push({ phaseNumber: currentPhase, @@ -403,7 +413,7 @@ export class BatchMiningService { participatingBatches: [...sortedBatches], }); - this.logger.log(`[buildMiningPhases] 阶段${currentPhase}(最终): ${remainingDays}天, 所有批次[${sortedBatches.join(',')}], 算力=${networkContribution.toFixed(2)}`); + this.logger.log(`[buildMiningPhases] 阶段${currentPhase}(最终): ${remainingDays}天, 所有批次[${sortedBatches.join(',')}], 参与算力=${participatingContribution.toFixed(2)}, 全网算力=${networkContribution.toFixed(2)}`); } return phases;