Browse Source

kmd main win maxconnections workaround

v0.25
pbca26 7 years ago
parent
commit
317840d299
  1. 8
      react/src/components/dashboard/settings/settings.panelUtils.js
  2. 2
      react/src/components/dashboard/walletsData/walletsData.js
  3. 121
      react/src/components/dashboard/walletsProgress/walletsProgress.js
  4. 32
      react/src/components/dashboard/walletsProgress/walletsProgress.render.js
  5. 4
      react/src/components/overrides.scss

8
react/src/components/dashboard/settings/settings.panelUtils.js

@ -33,10 +33,14 @@ export function setupAccordion(info) {
if (!singleChild) {
info.kids.forEach((child, i) => {
const { openByDefault } = child ? child.props : false;
if (singleOpen && activeSections.length === 0 && openByDefault) {
if (singleOpen &&
activeSections.length === 0 &&
openByDefault) {
activeSections.push(`panel-sec-${i}`);
}
if (!singleOpen && openByDefault) {
if (!singleOpen &&
openByDefault) {
activeSections.push(`panel-sec-${i}`);
}
});

2
react/src/components/dashboard/walletsData/walletsData.js

@ -85,6 +85,8 @@ class WalletsData extends React.Component {
displayClaimInterestUI() {
if (this.props.ActiveCoin &&
this.props.ActiveCoin.coin === 'KMD' &&
this.props.ActiveCoin.mode === 'native' &&
this.props.ActiveCoin.balance &&
this.props.ActiveCoin.balance.interest &&
this.props.ActiveCoin.balance.interest > 0) {

121
react/src/components/dashboard/walletsProgress/walletsProgress.js

@ -1,6 +1,10 @@
import React from 'react';
import { connect } from 'react-redux';
import { translate } from '../../../translate/translate';
import {
triggerToaster,
} from '../../../actions/actionCreators';
import Store from '../../../store';
import {
SyncErrorBlocksRender,
SyncPercentageRender,
@ -8,7 +12,7 @@ import {
TranslationComponentsRender,
ChainActivationNotificationRender,
VerifyingBlocksRender,
WalletsProgressRender
WalletsProgressRender,
} from './walletsProgress.render';
class WalletsProgress extends React.Component {
@ -16,8 +20,71 @@ class WalletsProgress extends React.Component {
super();
this.state = {
prevProgress: {},
isWindows: false,
isWindowsWorkaroundEnabled: false,
};
this.isFullySynced = this.isFullySynced.bind(this);
this.isWinSyncPercBelowThreshold = this.isWinSyncPercBelowThreshold.bind(this);
this.applyWindowsSyncWorkaround = this.applyWindowsSyncWorkaround.bind(this);
}
componentWillMount() {
const _mainWindow = window.require('electron').remote.getCurrentWindow();
let _isWindows;
try {
_isWindows = _mainWindow.isWindows;
} catch (e) {}
if (_isWindows) {
_mainWindow.getMaxconKMDConf()
.then((res) => {
if (!res ||
Number(res) !== 1) {
this.setState({
isWindowsWorkaroundEnabled: false,
isWindows: _isWindows,
});
} else {
this.setState({
isWindowsWorkaroundEnabled: true,
isWindows: _isWindows,
});
}
});
}
}
applyWindowsSyncWorkaround() {
const _mainWindow = window.require('electron').remote.getCurrentWindow();
_mainWindow.setMaxconKMDConf(1)
.then((res) => {
if (res) {
this.setState({
isWindowsWorkaroundEnabled: true,
});
Store.dispatch(
triggerToaster(
'Windows sync workaround is applied. Closing the app...',
translate('TOASTR.WALLET_NOTIFICATION'),
'success'
)
);
setTimeout(() => {
_mainWindow.appExit();
}, 2000);
} else {
Store.dispatch(
triggerToaster(
'Unable to apply Windows sync workaround',
translate('TOASTR.WALLET_NOTIFICATION'),
'error'
)
);
}
});
}
componentWillReceiveProps(props) {
@ -31,6 +98,7 @@ class WalletsProgress extends React.Component {
Number(this.state.prevProgress.longestchain) > 0) {
_progress.longestchain = this.state.prevProgress.longestchain;
}
this.setState(Object.assign({}, this.state, {
prevProgress: _progress,
}));
@ -39,18 +107,49 @@ class WalletsProgress extends React.Component {
prevProgress: props.ActiveCoin.progress,
}));
}
}
isFullySynced() {
const _progress = this.props.ActiveCoin.progress;
if (this.isWinSyncPercBelowThreshold() !== -777 &&
this.state.isWindowsWorkaroundEnabled &&
!this.isWinSyncPercBelowThreshold()) {
const _mainWindow = window.require('electron').remote.getCurrentWindow();
_mainWindow.setMaxconKMDConf()
.then((res) => {
if (res) {
this.setState({
isWindowsWorkaroundEnabled: false,
});
Store.dispatch(
triggerToaster(
'Current sync state reached 80% level. Windows sync workaround is disabled. Changes will be applied next time you start the app.',
translate('TOASTR.WALLET_NOTIFICATION'),
'info',
false
)
);
} else {
Store.dispatch(
triggerToaster(
'Unable to apply Windows sync workaround',
translate('TOASTR.WALLET_NOTIFICATION'),
'error'
)
);
}
});
}
}
if ((Number(_progress.balances) +
Number(_progress.validated) +
Number(_progress.bundles) +
Number(_progress.utxo)) / 4 === 100) {
return true;
isWinSyncPercBelowThreshold() {
if (this.state.prevProgress &&
this.state.prevProgress.longestchain &&
this.state.prevProgress.blocks) {
if (Number(this.state.prevProgress.blocks) * 100 / Number(this.state.prevProgress.longestchain) < 80) {
return true;
}
} else {
return false;
return -777;
}
}

32
react/src/components/dashboard/walletsProgress/walletsProgress.render.js

@ -98,12 +98,32 @@ export const TranslationComponentsRender = function(translationID) {
export const ChainActivationNotificationRender = function() {
if (this.props.ActiveCoin.coin !== 'CHIPS') {
return (
<div className="alert alert-info alert-dismissible margin-bottom-50">
<h4>
{ translate('INDEX.ACTIVATING_CHAIN') }&nbsp;
{ this.props.ActiveCoin.rescanInProgress ? (this.renderRescanProgress() ? `: ${this.renderRescanProgress().toFixed(2)}% ${translate('INDEX.PROGRESS_RESCANNING_BLOCKS')}` : translate('INDEX.PROGRESS_RESCANNING_BLOCKS')) : this.renderActivatingBestChainProgress() }
</h4>
<p>{ this.renderLB('INDEX.KMD_STARTED') }</p>
<div>
<div className={ 'alert alert-info alert-dismissible margin-bottom-' + (this.state.isWindows && !this.state.isWindowsWorkaroundEnabled && this.isWinSyncPercBelowThreshold() && this.props.ActiveCoin && this.props.ActiveCoin.mode === 'native' && this.props.ActiveCoin.coin === 'KMD' ? 20 : 50) }>
<h4>
{ translate('INDEX.ACTIVATING_CHAIN') }&nbsp;
{ this.props.ActiveCoin.rescanInProgress ? (this.renderRescanProgress() ? `: ${this.renderRescanProgress().toFixed(2)}% ${translate('INDEX.PROGRESS_RESCANNING_BLOCKS')}` : translate('INDEX.PROGRESS_RESCANNING_BLOCKS')) : this.renderActivatingBestChainProgress() }
</h4>
<p>{ this.renderLB('INDEX.KMD_STARTED') }</p>
</div>
{ this.state.isWindows &&
!this.state.isWindowsWorkaroundEnabled &&
this.isWinSyncPercBelowThreshold() &&
this.props.ActiveCoin &&
this.props.ActiveCoin.mode === 'native' &&
this.props.ActiveCoin.coin === 'KMD' &&
<div className="alert alert-warning alert-dismissible margin-bottom-50">
<p>Slow sync speed on Windows? Try this workaround.</p>
<p>It will add maxconnections=1 in komodo.conf file and force close the app.</p>
<p className="padding-bottom-15">Please run the app again after that.</p>
<button
type="button"
className="btn btn-info waves-effect waves-light win-sync-workaround-btn"
onClick={ this.applyWindowsSyncWorkaround }>
Apply workaround
</button>
</div>
}
</div>
);
} else {

4
react/src/components/overrides.scss

@ -468,4 +468,8 @@ select{
.dashboard-claim-interest-btn {
padding: 4px 14px 4px 7px;
margin-left: 20px;
}
.win-sync-workaround-btn {
padding: 4px 7px;
}
Loading…
Cancel
Save