Browse Source

coin data load bugfix; restart basilisk instance

all-modes
pbca26 8 years ago
parent
commit
3556c353d5
  1. 44
      react/src/actions/actionCreators.js
  2. 6
      react/src/components/dashboard/coinTileItem.js
  3. 26
      react/src/components/dashboard/walletsData.js

44
react/src/actions/actionCreators.js

@ -347,10 +347,11 @@ export function iguanaAddCoin(coin, mode, acData) {
if (mode === 0) {
return dispatch => {
startIguanaInstance('basilisk', 'basilisk')
return _iguanaAddCoin(dispatch);
/*startIguanaInstance('basilisk', 'basilisk')
.then(function(json) {
_iguanaAddCoin(dispatch);
});
});*/
}
} else {
return dispatch => {
@ -2004,7 +2005,6 @@ function connectAllNotaryNodes(json, dispatch) {
}
export function startIguanaInstance(mode, coin) {
console.log('startIguanaInstance', mode + ' ' + coin);
return new Promise((resolve, reject) => {
fetch('http://127.0.0.1:' + Config.agamaPort + '/shepherd/forks', {
method: 'POST',
@ -2025,6 +2025,44 @@ export function startIguanaInstance(mode, coin) {
});
}
export function getIguanaInstancesList() {
return new Promise((resolve, reject) => {
fetch('http://127.0.0.1:' + Config.agamaPort + '/shepherd/forks', {
method: 'GET',
headers: {
'Content-Type': 'application/json',
},
})
.catch(function(error) {
console.log(error);
dispatch(triggerToaster(true, 'getIguanaInstanceList', 'Error', 'error'));
})
.then(response => response.json())
.then(json => resolve(json))
});
}
export function restartIguanaInstance(pmid) {
return new Promise((resolve, reject) => {
fetch('http://127.0.0.1:' + Config.agamaPort + '/shepherd/forks/restart?pmid=' + pmid, {
method: 'GET',
headers: {
'Content-Type': 'application/json',
},
/*body: JSON.stringify({
mode,
coin
}),*/
})
.catch(function(error) {
console.log(error);
dispatch(triggerToaster(true, 'restartIguanaInstance', 'Error', 'error'));
})
.then(response => response.json())
.then(json => resolve(json))
});
}
export function connectNotaries() {
const payload = {
'userpass': 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'),

6
react/src/components/dashboard/coinTileItem.js

@ -34,6 +34,7 @@ class CoinTileItem extends React.Component {
dispatchCoinActions(coin, mode) {
if (mode === 'native') {
Store.dispatch(iguanaActiveHandle(true));
Store.dispatch(getSyncInfoNative(coin));
Store.dispatch(getKMDBalanceTotal(coin));
Store.dispatch(getNativeTxHistory(coin));
@ -41,18 +42,21 @@ class CoinTileItem extends React.Component {
Store.dispatch(getKMDOPID(null, coin));
}
if (mode === 'full') {
Store.dispatch(iguanaActiveHandle(true));
Store.dispatch(getSyncInfo(coin));
Store.dispatch(iguanaEdexBalance(coin, mode));
Store.dispatch(getKMDAddressesNative(coin, mode)); //getAddressesByAccount(coin));
Store.dispatch(getFullTransactionsList(coin));
}
if (mode === 'basilisk') {
console.log('dispatchCoinActions', mode);
const useAddress = this.props.ActiveCoin.mainBasiliskAddress ? this.props.ActiveCoin.mainBasiliskAddress : this.props.Dashboard.activeHandle[coin];
Store.dispatch(iguanaActiveHandle(true));
if (this.props && this.props.Dashboard && this.props.Dashboard.activeHandle && this.props.Dashboard.activeHandle[coin]) {
Store.dispatch(getShepherdCache(this.props.Dashboard.activeHandle.pubkey));
Store.dispatch(getBasiliskTransactionsList(coin, useAddress));
Store.dispatch(getKMDAddressesNative(coin, mode, useAddress));
Store.dispatch(getShepherdCache(this.props.Dashboard.activeHandle.pubkey));
Store.dispatch(iguanaEdexBalance(coin, mode));
}
}

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

@ -14,7 +14,9 @@ import {
connectNotaries,
toggleViewCacheModal,
fetchNewCacheData,
fetchUtxoCache
fetchUtxoCache,
getIguanaInstancesList,
restartIguanaInstance
} from '../../actions/actionCreators';
import Store from '../../store';
@ -53,6 +55,7 @@ class WalletsData extends React.Component {
this._toggleViewCacheModal = this._toggleViewCacheModal.bind(this);
this.toggleCacheApi = this.toggleCacheApi.bind(this);
this._fetchUtxoCache = this._fetchUtxoCache.bind(this);
this.restartBasiliskInstance = this.restartBasiliskInstance.bind(this);
socket.on('messages', msg => this.updateSocketsData(msg));
}
@ -93,6 +96,18 @@ class WalletsData extends React.Component {
}
}
restartBasiliskInstance() {
getIguanaInstancesList().then(function(json) {
for (let port in json.result) {
if (json.result[port].mode === 'basilisk') {
restartIguanaInstance(json.result[port].pmid).then(function(json) {
console.log('restartBasiliskInstance', json);
});
}
}
});
}
removeAndFetchNewCache() {
Store.dispatch(deleteCacheFile({
'pubkey': this.props.Dashboard.activeHandle.pubkey,
@ -426,7 +441,7 @@ class WalletsData extends React.Component {
</li>
<li data-edexcoin="COIN" role="presentation" className={!this.state.useCache ? 'hide' : ''}>
<a className="btn_edexcoin_dashboard_fetchdata" data-edexcoin="COIN" id="btn_edexcoin_dashboard_fetchdata" role="menuitem" onClick={this.basiliskRefreshAction}>
<i className="icon fa-cloud-download" aria-hidden="true"></i> {translate('INDEX.FETCH_WALLET_DATA')}
<i className="icon fa-cloud-download" aria-hidden="true"></i> {translate('INDEX.FETCH_WALLET_DATA')}
</a>
</li>
<li data-edexcoin="COIN" role="presentation" className={!this.state.useCache ? 'hide' : ''}>
@ -435,10 +450,15 @@ class WalletsData extends React.Component {
</a>
</li>
<li data-edexcoin="COIN" role="presentation" className={!this.state.useCache ? 'hide' : ''}>
<a className="btn_edexcoin_dashboard_refetchdata" data-edexcoin="COIN" id="btn_edexcoin_dashboard_refetchdata" role="menuitem" onClick={this._fetchUtxoCache}>
<a role="menuitem" onClick={this._fetchUtxoCache}>
<i className="icon fa-history" aria-hidden="true"></i> Update UTXO
</a>
</li>
<li data-edexcoin="COIN" role="presentation" className={!this.state.useCache ? 'hide' : ''}>
<a role="menuitem" onClick={this.restartBasiliskInstance}>
<i className="icon fa-refresh" aria-hidden="true"></i> Restart Basilisk Instance
</a>
</li>
<li data-edexcoin="COIN" role="presentation" className={!this.state.useCache ? 'hide' : ''}>
<a className="btn_edexcoin_dashboard_fetchdata" role="menuitem" onClick={this._toggleViewCacheModal}>
<i className="icon fa-list-alt" aria-hidden="true"></i> {translate('INDEX.VIEW_CACHE_DATA')}

Loading…
Cancel
Save