Skip to content

Commit

Permalink
fix(smeshing): fix creating pos data and smesher initialization
Browse files Browse the repository at this point in the history
  • Loading branch information
brusherru committed Jun 27, 2022
1 parent 0652d7d commit 869fd21
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 24 deletions.
2 changes: 1 addition & 1 deletion app/components/node/SmesherLog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ const SmesherLog = ({
<DateText>
<ReactTimeago date={initTimestamp} />
</DateText>
<LogText>Initializing smesher</LogText>
<LogText>Started creating PoS data</LogText>
</LogEntry>
</>
) : null}
Expand Down
8 changes: 1 addition & 7 deletions app/infra/eventsService/eventsService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ import {
import { showClosingAppModal } from '../../redux/ui/actions';
// Temporary solution to provide types
// Could be replaced using something like `electron-ipcfy`
import { LOCAL_NODE_API_URL } from '../../../shared/constants';
import TransactionManager from '../../../desktop/TransactionManager';
import updaterSlice from '../../redux/updater/slice';
import { CurrentLayer, GlobalStateHash } from '../../types/events';
Expand Down Expand Up @@ -157,12 +156,7 @@ class EventsService {
static getEstimatedRewards = () =>
ipcRenderer.invoke(ipcConsts.SMESHER_GET_ESTIMATED_REWARDS);

static startSmeshing = async (postSetupOpts: PostSetupOpts, netId) => {
await ipcRenderer.invoke(ipcConsts.SWITCH_API_PROVIDER, {
apiUrl: LOCAL_NODE_API_URL,
netId,
});
await ipcRenderer.invoke(ipcConsts.N_M_START_NODE);
static startSmeshing = async (postSetupOpts: PostSetupOpts) => {
ipcRenderer.send(ipcConsts.SMESHER_START_SMESHING, postSetupOpts);
};

Expand Down
28 changes: 12 additions & 16 deletions app/redux/smesher/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { eventsService } from '../../infra/eventsService';
import { AppThDispatch, GetState } from '../../types';
import { SmeshingOpts } from '../../../shared/types';
import { addErrorPrefix } from '../../infra/utils';
import { getNetworkId } from '../network/selectors';
import { setUiError } from '../ui/actions';
import {
getSmeshingOpts,
Expand All @@ -27,24 +26,21 @@ export const startSmeshing = ({
numUnits,
provider,
throttle,
}: SmeshingOpts) => async (dispatch: AppThDispatch, getState: GetState) => {
}: SmeshingOpts) => async (dispatch: AppThDispatch) => {
try {
const state = getState();
const curNetId = getNetworkId(state);
// TODO: Replace hardcoded `numFiles: 1` with something reasonable?
await eventsService.startSmeshing(
{
coinbase,
dataDir,
numUnits,
numFiles: 1,
computeProviderId: provider,
throttle,
},
curNetId
);
await eventsService.startSmeshing({
coinbase,
dataDir,
numUnits,
// TODO: Replace hardcoded `numFiles: 1` with something reasonable?
numFiles: 1,
computeProviderId: provider,
throttle,
});

localStorage.setItem('smesherInitTimestamp', `${new Date().getTime()}`);
localStorage.removeItem('smesherSmeshingTimestamp');

dispatch({
type: STARTED_SMESHING,
payload: { coinbase, dataDir, numUnits, provider, throttle },
Expand Down
1 change: 1 addition & 0 deletions desktop/main/sources/wallet.ipc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,7 @@ const handleWalletIpcRequests = (
//
$smeshingStarted.pipe(
switchMap(() => combineLatest([$wallet, $walletPath])),
first(),
filter(
(pair): pair is [Wallet, string] =>
Boolean(pair[0]) && typeof pair[1] === 'string'
Expand Down

0 comments on commit 869fd21

Please sign in to comment.