Skip to content

Commit

Permalink
Merge commit '99fed6d4e28d2e6749d07f303055589525c1a09e' into checkpoi…
Browse files Browse the repository at this point in the history
…nt/main_from_release_2.1.0_99fed6d4e28d2e6749d07f303055589525c1a09e
  • Loading branch information
paninaro committed Sep 14, 2023
2 parents 8432b81 + 99fed6d commit 4b0fcb5
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 4b0fcb5

Please sign in to comment.