From 416495a398b06393d857a9b3d53ae76904292db5 Mon Sep 17 00:00:00 2001 From: hailin Date: Sat, 17 Jan 2026 09:46:25 -0800 Subject: [PATCH] fix(mining): correctly parse network-progress API response MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The API returns {success: true, data: {...}} but code was accessing progressResult.currentContributionPerTree directly instead of progressResult.data.currentContributionPerTree. This caused: - totalTreeCount to be 0 (undefined → 0) - networkTotalContribution to be 0 - No mining distributions happening Co-Authored-By: Claude Opus 4.5 --- .../services/network-sync.service.ts | 20 ++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/backend/services/mining-service/src/application/services/network-sync.service.ts b/backend/services/mining-service/src/application/services/network-sync.service.ts index 37c47ec8..756c772a 100644 --- a/backend/services/mining-service/src/application/services/network-sync.service.ts +++ b/backend/services/mining-service/src/application/services/network-sync.service.ts @@ -145,24 +145,26 @@ export class NetworkSyncService { throw new Error(`Failed to fetch network progress: ${progressResponse.status}`); } const progressResult = await progressResponse.json(); + // 从响应中提取 data 字段 + const progressData = progressResult.data || progressResult; // 防御性检查:确保必要字段存在 - if (!progressResult.currentContributionPerTree) { + if (!progressData.currentContributionPerTree) { this.logger.warn( `Network progress missing currentContributionPerTree, response: ${JSON.stringify(progressResult)}`, ); // 使用默认值继续 - progressResult.currentContributionPerTree = '20'; + progressData.currentContributionPerTree = '20'; } await this.handleNetworkProgressUpdated({ - totalTreeCount: progressResult.totalTreeCount || 0, - totalAdoptionOrders: progressResult.totalAdoptionOrders || 0, - totalAdoptedUsers: progressResult.totalAdoptedUsers || 0, - currentUnit: progressResult.currentUnit || 1, - currentMultiplier: progressResult.currentMultiplier || '1', - currentContributionPerTree: progressResult.currentContributionPerTree, - nextUnitTreeCount: progressResult.nextUnitTreeCount || 100000, + totalTreeCount: progressData.totalTreeCount || 0, + totalAdoptionOrders: progressData.totalAdoptionOrders || 0, + totalAdoptedUsers: progressData.totalAdoptedUsers || 0, + currentUnit: progressData.currentUnit || 1, + currentMultiplier: progressData.currentMultiplier || '1', + currentContributionPerTree: progressData.currentContributionPerTree, + nextUnitTreeCount: progressData.nextUnitTreeCount || 100000, }); // 3. 获取最新的 MiningConfig 来返回结果