Skip to content

Commit

Permalink
Fixed an issue where expected average passed filter count was wrong (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
ChiaMineJP authored Sep 14, 2023
1 parent be32f6c commit 99fed6d
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions packages/gui/src/components/harvest/HarvesterOverview.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { NewFarmingInfo } from '@chia-network/api';
import { useGetBlockchainStateQuery, useGetHarvestersQuery, useGetNewFarmingInfoQuery } from '@chia-network/api-react';
import { Flex, FormatBytes, FormatLargeNumber, CardSimple, useCurrencyCode } from '@chia-network/core';
import { Trans } from '@lingui/macro';
Expand Down Expand Up @@ -65,24 +66,29 @@ export default function HarvesterOverview() {
}

const eligiblePlotsPerSp: Record<string, { totalPlots: number; passedFilter: number }> = {};
let latestTotalPlots = 0;
const latestTotalPlotsForNode: Record<string, number> = {};
for (let i = 0; i < newFarmingInfo.length; i++) {
const nfi = newFarmingInfo[i];
const nfi: NewFarmingInfo = newFarmingInfo[i];
eligiblePlotsPerSp[nfi.signagePoint] = eligiblePlotsPerSp[nfi.signagePoint] || {
totalPlots: 0,
passedFilter: 0,
};
eligiblePlotsPerSp[nfi.signagePoint].totalPlots += nfi.totalPlots;
eligiblePlotsPerSp[nfi.signagePoint].passedFilter += nfi.passedFilter;
if (i === 0) {
latestTotalPlots = nfi.totalPlots;

// `newFarmingInfo` is already sorted by time(descend). So the latest farming info data comes first.
if (!latestTotalPlotsForNode[nfi.nodeId]) {
latestTotalPlotsForNode[nfi.nodeId] = nfi.totalPlots;
}

if (Object.keys(eligiblePlotsPerSp).length > 64) {
// Only cares last 64 sps
break;
}
}

const latestTotalPlots = Object.values(latestTotalPlotsForNode).reduce((acc, val) => acc + val, 0);

let sumPassedFilter = 0;
const sps = Object.keys(eligiblePlotsPerSp);
for (let i = 0; i < sps.length; i++) {
Expand Down

0 comments on commit 99fed6d

Please sign in to comment.