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;