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 来返回结果