fix(batch-mining): 修复计算逻辑,批量补发用户只占全网70%
- 添加 BATCH_USERS_NETWORK_RATIO 常量(0.70) - 计算全网算力时:实际全网算力 = 用户算力 / 0.7 - 修正预期结果约为 70,958 而非 104,656 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
16daa7403c
commit
e79d42db61
|
|
@ -90,6 +90,8 @@ 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 PERSONAL_RATE = new Decimal('0.70'); // 个人算力占比 70%
|
||||||
const SECONDS_PER_DAY = 86400;
|
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'] = [];
|
const batchResults: BatchMiningPreviewResult['batches'] = [];
|
||||||
|
|
||||||
// 计算累计全网算力(最终状态)
|
// 计算累计全网算力(最终状态)
|
||||||
let finalNetworkContribution = new Decimal(0);
|
// 这些用户只占全网的70%,所以全网算力 = 用户算力 / 0.7
|
||||||
|
let totalUserContribution = new Decimal(0);
|
||||||
for (const contribution of batchContributions.values()) {
|
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) {
|
for (const batchNum of sortedBatches) {
|
||||||
const batchItems = batchGroups.get(batchNum)!;
|
const batchItems = batchGroups.get(batchNum)!;
|
||||||
|
|
@ -364,11 +369,14 @@ export class BatchMiningService {
|
||||||
const phaseDays = currentPreMineDays - nextPreMineDays;
|
const phaseDays = currentPreMineDays - nextPreMineDays;
|
||||||
|
|
||||||
if (phaseDays > 0) {
|
if (phaseDays > 0) {
|
||||||
// 计算该阶段的全网算力
|
// 计算该阶段参与用户的算力
|
||||||
let networkContribution = new Decimal(0);
|
let participatingContribution = new Decimal(0);
|
||||||
for (const batch of participatingBatches) {
|
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({
|
phases.push({
|
||||||
phaseNumber: currentPhase,
|
phaseNumber: currentPhase,
|
||||||
|
|
@ -379,7 +387,7 @@ export class BatchMiningService {
|
||||||
participatingBatches: [...participatingBatches],
|
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++;
|
currentPhase++;
|
||||||
usedDays += phaseDays;
|
usedDays += phaseDays;
|
||||||
}
|
}
|
||||||
|
|
@ -389,10 +397,12 @@ export class BatchMiningService {
|
||||||
const remainingDays = maxTotalMiningDays - usedDays;
|
const remainingDays = maxTotalMiningDays - usedDays;
|
||||||
if (remainingDays > 0) {
|
if (remainingDays > 0) {
|
||||||
// 所有批次都参与
|
// 所有批次都参与
|
||||||
let networkContribution = new Decimal(0);
|
let participatingContribution = new Decimal(0);
|
||||||
for (const batch of sortedBatches) {
|
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({
|
phases.push({
|
||||||
phaseNumber: currentPhase,
|
phaseNumber: currentPhase,
|
||||||
|
|
@ -403,7 +413,7 @@ export class BatchMiningService {
|
||||||
participatingBatches: [...sortedBatches],
|
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;
|
return phases;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue