Skip to content

Commit

Permalink
Merge branch 'main' into paninaro.update_package_lock
Browse files Browse the repository at this point in the history
  • Loading branch information
paninaro committed Jul 19, 2023
2 parents f620420 + c5387ea commit 709ed78
Show file tree
Hide file tree
Showing 94 changed files with 3,877 additions and 539 deletions.
27 changes: 27 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export default function useGetTotalHarvestersSummaryQuery() {
let plots = new BigNumber(0);
let plotsProcessed = new BigNumber(0);
let totalPlotSize = new BigNumber(0);
let totalEffectivePlotSize = new BigNumber(0);
let plotFilesTotal = new BigNumber(0);
let initialized = !!data?.length;
let initializedHarvesters = 0;
Expand All @@ -22,6 +23,7 @@ export default function useGetTotalHarvestersSummaryQuery() {
failedToOpenFilenames = failedToOpenFilenames.plus(harvester.failedToOpenFilenames);
noKeyFilenames = noKeyFilenames.plus(harvester.noKeyFilenames);
totalPlotSize = totalPlotSize.plus(harvester.totalPlotSize);
totalEffectivePlotSize = totalEffectivePlotSize.plus(harvester.totalEffectivePlotSize);
plots = plots.plus(harvester.plots);

if (harvester.syncing) {
Expand All @@ -45,6 +47,7 @@ export default function useGetTotalHarvestersSummaryQuery() {
plots,
plotsProcessed,
totalPlotSize,
totalEffectivePlotSize,
plotFilesTotal,
initialized,
initializedHarvesters,
Expand All @@ -63,6 +66,7 @@ export default function useGetTotalHarvestersSummaryQuery() {
harvesters: data?.length ?? 0,
plotsProcessed: memoized.plotsProcessed,
totalPlotSize: memoized.totalPlotSize,
totalEffectivePlotSize: memoized.totalEffectivePlotSize,
plotFilesTotal: memoized.plotFilesTotal,
initializedHarvesters: memoized.initializedHarvesters,
};
Expand Down
4 changes: 4 additions & 0 deletions packages/api-react/src/hooks/useService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ export default function useService(
}).unwrap();

refetch();
} catch (e) {
console.error(e);
} finally {
setIsStarting(false);
}
Expand All @@ -99,6 +101,8 @@ export default function useService(
}).unwrap();

refetch();
} catch (e) {
console.error(e);
} finally {
setIsStopping(false);
}
Expand Down
5 changes: 4 additions & 1 deletion packages/api-react/src/services/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,10 @@ export const clientApi = apiWithTag.injectEndpoints({
}),

clientStartService: mutation(build, Client, 'startService'),

clientStopService: mutation(build, Client, 'stopService'),
}),
});

export const { useCloseMutation, useGetStateQuery, useClientStartServiceMutation } = clientApi;
export const { useCloseMutation, useGetStateQuery, useClientStartServiceMutation, useClientStopServiceMutation } =
clientApi;
65 changes: 42 additions & 23 deletions packages/api-react/src/services/daemon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ export const daemonApi = apiWithTag.injectEndpoints({
installed,
canInstall,
bladebitMemoryWarning,
cudaSupport,
} = plotters[plotterName] as PlotterApi;

if (!plotterName.startsWith('bladebit')) {
Expand All @@ -142,24 +143,11 @@ export const daemonApi = apiWithTag.injectEndpoints({

// if (plotterName.startsWith('bladebit'))
const majorVersion = typeof version === 'string' ? +version.split('.')[0] : 0;
if (majorVersion > 1) {
const bbDisk = PlotterName.BLADEBIT_DISK;
availablePlotters[bbDisk] = {
displayName,
version: `${version} (Disk plot)`,
options: optionsForPlotter(bbDisk),
defaults: defaultsForPlotter(bbDisk),
installInfo: {
installed,
canInstall,
bladebitMemoryWarning,
},
};

if (majorVersion <= 1) {
const bbRam = PlotterName.BLADEBIT_RAM;
availablePlotters[bbRam] = {
displayName,
version: `${version} (RAM plot)`,
version: typeof version === 'string' ? `${version} (RAM plot)` : version,
options: optionsForPlotter(bbRam),
defaults: defaultsForPlotter(bbRam),
installInfo: {
Expand All @@ -168,17 +156,45 @@ export const daemonApi = apiWithTag.injectEndpoints({
bladebitMemoryWarning,
},
};
} else {
const bbRam = PlotterName.BLADEBIT_RAM;
availablePlotters[bbRam] = {
return;
}
const bbDisk = PlotterName.BLADEBIT_DISK;
availablePlotters[bbDisk] = {
displayName,
version: `${version} (Disk plot)`,
options: optionsForPlotter(bbDisk),
defaults: defaultsForPlotter(bbDisk),
installInfo: {
installed,
canInstall,
bladebitMemoryWarning,
},
};

const bbRam = PlotterName.BLADEBIT_RAM;
availablePlotters[bbRam] = {
displayName,
version: `${version} (RAM plot)`,
options: optionsForPlotter(bbRam),
defaults: defaultsForPlotter(bbRam),
installInfo: {
installed,
canInstall,
bladebitMemoryWarning,
},
};
if (cudaSupport) {
const bbCuda = PlotterName.BLADEBIT_CUDA;
availablePlotters[bbCuda] = {
displayName,
version: `${version} (RAM plot)`,
options: optionsForPlotter(bbRam),
defaults: defaultsForPlotter(bbRam),
version: `${version} (CUDA plot)`,
options: optionsForPlotter(bbCuda),
defaults: defaultsForPlotter(bbCuda),
installInfo: {
installed: false,
canInstall: false,
installed,
canInstall,
bladebitMemoryWarning,
cudaSupport,
},
};
}
Expand All @@ -196,6 +212,8 @@ export const daemonApi = apiWithTag.injectEndpoints({
transformResponse: (response) => response.version,
providesTags: [{ type: 'RunningServices', id: 'LIST' }],
}),

getKeysForPlotting: query(build, Daemon, 'getKeysForPlotting'),
}),
});

Expand All @@ -211,6 +229,7 @@ export const {
useMigrateKeyringMutation,
useUnlockKeyringMutation,
useGetVersionQuery,
useGetKeysForPlottingQuery,

useGetPlottersQuery,
useStopPlottingMutation,
Expand Down
74 changes: 69 additions & 5 deletions packages/api-react/src/services/farmer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ export const apiWithTag = api.enhanceEndpoints({
'HarvestersSummary',
'HarvesterPlotsKeysMissing',
'HarvesterPlotsDuplicates',
'MissingSignagePoints',
'FilterChallengeStat',
'partialStats',
],
});

Expand All @@ -32,7 +35,12 @@ export const farmerApi = apiWithTag.injectEndpoints({
providesTags: [{ type: 'Harvesters', id: 'LIST' }],
onCacheEntryAdded: onCacheEntryAddedInvalidate(baseQuery, api, [
{
command: 'onHarvesterChanged',
command: 'onHarvesterUpdated',
service: Farmer,
endpoint: 'getHarvesters',
},
{
command: 'onHarvesterRemoved',
service: Farmer,
endpoint: 'getHarvesters',
},
Expand Down Expand Up @@ -231,25 +239,75 @@ export const farmerApi = apiWithTag.injectEndpoints({
{ type: 'Pools', id: 'LIST' },
]
: [{ type: 'Pools', id: 'LIST' }],
onCacheEntryAdded: onCacheEntryAddedInvalidate(baseQuery, api, [
{
command: 'onSubmittedPartial',
service: Farmer,
endpoint: 'getPoolState',
},
{
command: 'onFailedPartial',
service: Farmer,
endpoint: 'getPoolState',
},
]),
}),

getPartialStatsOffset: query(build, Farmer, 'getPartialStatsOffset', {
providesTags: ['partialStats'],
}),

resetPartialStats: mutation(build, Farmer, 'resetPartialStats', {
invalidatesTags: ['partialStats'],
}),

setPayoutInstructions: mutation(build, Farmer, 'setPayoutInstructions', {
invalidatesTags: (_result, _error, { launcherId }) => [{ type: 'PayoutInstructions', id: launcherId }],
}),

getFarmingInfo: query(build, Farmer, 'getFarmingInfo', {
getNewFarmingInfo: query(build, Farmer, 'getNewFarmingInfo', {
onCacheEntryAdded: onCacheEntryAddedInvalidate(baseQuery, api, [
{
command: 'onFarmingInfoChanged',
service: Farmer,
endpoint: 'getNewFarmingInfo',
},
]),
}),

getMissingSignagePoints: query(build, Farmer, 'getMissingSignagePoints', {
providesTags: ['MissingSignagePoints'],
onCacheEntryAdded: onCacheEntryAddedInvalidate(baseQuery, api, [
{
command: 'onNewSignagePoint',
service: Farmer,
endpoint: 'getMissingSignagePoints',
},
]),
}),

resetMissingSignagePoints: mutation(build, Farmer, 'resetMissingSignagePoints', {
invalidatesTags: ['MissingSignagePoints'],
}),

getFilterChallengeStat: query(build, Farmer, 'getFilterChallengeStat', {
providesTags: ['FilterChallengeStat'],
onCacheEntryAdded: onCacheEntryAddedInvalidate(baseQuery, api, [
{
command: 'onFarmingInfoChanged',
service: Farmer,
endpoint: 'getFarmingInfo',
endpoint: 'getFilterChallengeStat',
},
]),
}),

resetFilterChallengeStat: mutation(build, Farmer, 'resetFilterChallengeStat', {
invalidatesTags: ['FilterChallengeStat'],
}),
}),
});

// TODO add new farming info query and event for last_attepmtp_proofs
// TODO add new farming info query and event for last_attempt_proofs

export const {
useFarmerPingQuery,
Expand All @@ -268,5 +326,11 @@ export const {
useGetSignagePointsQuery,
useGetPoolStateQuery,
useSetPayoutInstructionsMutation,
useGetFarmingInfoQuery,
useGetNewFarmingInfoQuery,
useGetMissingSignagePointsQuery,
useResetMissingSignagePointsMutation,
useGetFilterChallengeStatQuery,
useResetFilterChallengeStatMutation,
useGetPartialStatsOffsetQuery,
useResetPartialStatsMutation,
} = farmerApi;
25 changes: 24 additions & 1 deletion packages/api-react/src/services/harvester.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import { Harvester } from '@chia-network/api';

import api, { baseQuery } from '../api';
import onCacheEntryAddedInvalidate from '../utils/onCacheEntryAddedInvalidate';
import { query, mutation } from '../utils/reduxToolkitEndpointAbstractions';
import { apiWithTag } from './farmer';

const apiWithTag2 = apiWithTag.enhanceEndpoints({
addTagTypes: ['Plots', 'PlotDirectories'],
addTagTypes: ['Plots', 'PlotDirectories', 'harvesterConfig'],
});

export const harvesterApi = apiWithTag2.injectEndpoints({
Expand Down Expand Up @@ -71,6 +73,24 @@ export const harvesterApi = apiWithTag2.injectEndpoints({
{ type: 'PlotDirectories', id: dirname },
],
}),

getHarvesterConfig: query(build, Harvester, 'getHarvesterConfig', {
providesTags: ['harvesterConfig'],
}),

updateHarvesterConfig: mutation(build, Harvester, 'updateHarvesterConfig', {
invalidatesTags: ['harvesterConfig'],
}),

getFarmingInfo: query(build, Harvester, 'getFarmingInfo', {
onCacheEntryAdded: onCacheEntryAddedInvalidate(baseQuery, api, [
{
command: 'onFarmingInfoChanged',
service: Harvester,
endpoint: 'getFarmingInfo',
},
]),
}),
}),
});

Expand All @@ -81,4 +101,7 @@ export const {
useGetPlotDirectoriesQuery,
useAddPlotDirectoryMutation,
useRemovePlotDirectoryMutation,
useGetFarmingInfoQuery,
useGetHarvesterConfigQuery,
useUpdateHarvesterConfigMutation,
} = harvesterApi;
Loading

0 comments on commit 709ed78

Please sign in to comment.