fix(batch-mining): 修正70%比例计算逻辑

- 移除 PERSONAL_RATE,避免70%被乘两次
- 用户算力 = 棵数 × 22617(不再乘70%)
- 全网算力 = 用户算力 / 0.7(70%体现在这里)
- 预期结果:(1000000/365/2)*70%*74 = 70958.90411

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
hailin 2026-01-21 21:07:35 -08:00
parent e79d42db61
commit 97b3a20a7c
1 changed files with 12 additions and 14 deletions

View File

@ -88,10 +88,9 @@ export interface BatchMiningPreviewResult {
// 常量 // 常量
const BASE_CONTRIBUTION_PER_TREE = new Decimal('22617'); // 每棵树的基础算力 const BASE_CONTRIBUTION_PER_TREE = new Decimal('22617'); // 每棵树的基础算力
const PERSONAL_RATE = new Decimal('0.70'); // 个人算力占比 70%
const SECONDS_PER_DAY = 86400; const SECONDS_PER_DAY = 86400;
// 批量补发用户占全网算力的比例这些用户只占全网的70%还有30%是其他用户 // 用户算力占全网算力的比例用户占70%30%是系统、运营、层级、团队的
const BATCH_USERS_NETWORK_RATIO = new Decimal('0.70'); const USER_NETWORK_RATIO = new Decimal('0.70');
/** /**
* *
@ -237,13 +236,13 @@ export class BatchMiningService {
const batchResults: BatchMiningPreviewResult['batches'] = []; const batchResults: BatchMiningPreviewResult['batches'] = [];
// 计算累计全网算力(最终状态) // 计算累计全网算力(最终状态)
// 这些用户只占全网的70%,所以全网算力 = 用户算力 / 0.7 // 用户只占全网的70%30%是系统、运营、层级、团队),所以全网算力 = 用户算力 / 0.7
let totalUserContribution = new Decimal(0); let totalUserContribution = new Decimal(0);
for (const contribution of batchContributions.values()) { for (const contribution of batchContributions.values()) {
totalUserContribution = totalUserContribution.plus(contribution); totalUserContribution = totalUserContribution.plus(contribution);
} }
const finalNetworkContribution = totalUserContribution.dividedBy(BATCH_USERS_NETWORK_RATIO); const finalNetworkContribution = totalUserContribution.dividedBy(USER_NETWORK_RATIO);
this.logger.log(`[preview] 用户总算力: ${totalUserContribution.toFixed(2)}, 全网算力(70%): ${finalNetworkContribution.toFixed(2)}`); this.logger.log(`[preview] 用户总算力: ${totalUserContribution.toFixed(2)}, 全网算力(用户占70%): ${finalNetworkContribution.toFixed(2)}`);
for (const batchNum of sortedBatches) { for (const batchNum of sortedBatches) {
const batchItems = batchGroups.get(batchNum)!; const batchItems = batchGroups.get(batchNum)!;
@ -375,8 +374,8 @@ export class BatchMiningService {
participatingContribution = participatingContribution.plus(batchContributions.get(batch) || 0); participatingContribution = participatingContribution.plus(batchContributions.get(batch) || 0);
} }
// 实际全网算力 = 参与用户算力 / 用户占比 // 实际全网算力 = 参与用户算力 / 用户占比
// 因为这些用户只占全网的70%,所以全网算力 = 用户算力 / 0.7 // 因为用户只占全网的70%30%是系统、运营、层级、团队),所以全网算力 = 用户算力 / 0.7
const networkContribution = participatingContribution.dividedBy(BATCH_USERS_NETWORK_RATIO); const networkContribution = participatingContribution.dividedBy(USER_NETWORK_RATIO);
phases.push({ phases.push({
phaseNumber: currentPhase, phaseNumber: currentPhase,
@ -402,7 +401,7 @@ export class BatchMiningService {
participatingContribution = participatingContribution.plus(batchContributions.get(batch) || 0); participatingContribution = participatingContribution.plus(batchContributions.get(batch) || 0);
} }
// 实际全网算力 = 参与用户算力 / 用户占比 // 实际全网算力 = 参与用户算力 / 用户占比
const networkContribution = participatingContribution.dividedBy(BATCH_USERS_NETWORK_RATIO); const networkContribution = participatingContribution.dividedBy(USER_NETWORK_RATIO);
phases.push({ phases.push({
phaseNumber: currentPhase, phaseNumber: currentPhase,
@ -716,12 +715,11 @@ export class BatchMiningService {
} }
/** /**
* 70% *
* = × / × 70% * = × /
* 70%/0.7=
*/ */
private calculateUserContribution(treeCount: number): Decimal { private calculateUserContribution(treeCount: number): Decimal {
return BASE_CONTRIBUTION_PER_TREE return BASE_CONTRIBUTION_PER_TREE.times(treeCount);
.times(treeCount)
.times(PERSONAL_RATE);
} }
} }