@ -378,10 +378,17 @@ NetworkPreferences Main::netPrefs() const
publicIP . clear ( ) ;
}
NetworkPreferences ret ;
if ( isPublicAddress ( publicIP ) )
return NetworkPreferences ( publicIP , listenIP , ui - > port - > value ( ) , ui - > upnp - > isChecked ( ) ) ;
ret = NetworkPreferences ( publicIP , listenIP , ui - > port - > value ( ) , ui - > upnp - > isChecked ( ) ) ;
else
return NetworkPreferences ( listenIP , ui - > port - > value ( ) , ui - > upnp - > isChecked ( ) ) ;
ret = NetworkPreferences ( listenIP , ui - > port - > value ( ) , ui - > upnp - > isChecked ( ) ) ;
ret . discovery = m_privateChain . isEmpty ( ) ;
ret . pin = m_privateChain . isEmpty ( ) ;
return ret ;
}
void Main : : onKeysChanged ( )
@ -776,6 +783,30 @@ void Main::writeSettings()
s . setValue ( " windowState " , saveState ( ) ) ;
}
void Main : : setPrivateChain ( QString const & _private , bool _forceConfigure )
{
if ( m_privateChain = = _private & & ! _forceConfigure )
return ;
m_privateChain = _private ;
ui - > usePrivate - > setChecked ( ! m_privateChain . isEmpty ( ) ) ;
CanonBlockChain < Ethash > : : forceGenesisExtraData ( m_privateChain . isEmpty ( ) ? bytes ( ) : sha3 ( m_privateChain . toStdString ( ) ) . asBytes ( ) ) ;
// rejig blockchain now.
writeSettings ( ) ;
ui - > mine - > setChecked ( false ) ;
ui - > net - > setChecked ( false ) ;
web3 ( ) - > stopNetwork ( ) ;
web3 ( ) - > setNetworkPreferences ( netPrefs ( ) ) ;
ethereum ( ) - > reopenChain ( ) ;
readSettings ( true ) ;
installWatches ( ) ;
refreshAll ( ) ;
}
Secret Main : : retrieveSecret ( Address const & _address ) const
{
while ( true )
@ -852,8 +883,7 @@ void Main::readSettings(bool _skipGeometry)
ui - > listenIP - > setText ( s . value ( " listenIP " , " " ) . toString ( ) ) ;
ui - > port - > setValue ( s . value ( " port " , ui - > port - > value ( ) ) . toInt ( ) ) ;
ui - > nameReg - > setText ( s . value ( " nameReg " , " " ) . toString ( ) ) ;
m_privateChain = s . value ( " privateChain " , " " ) . toString ( ) ;
ui - > usePrivate - > setChecked ( m_privateChain . size ( ) ) ;
setPrivateChain ( s . value ( " privateChain " , " " ) . toString ( ) ) ;
ui - > verbosity - > setValue ( s . value ( " verbosity " , 1 ) . toInt ( ) ) ;
# if ETH_EVMJIT // We care only if JIT is enabled. Otherwise it can cause misconfiguration.
@ -1036,21 +1066,15 @@ void Main::on_exportState_triggered()
void Main : : on_usePrivate_triggered ( )
{
QString pc ;
if ( ui - > usePrivate - > isChecked ( ) )
{
m_privateChain = QInputDialog : : getText ( this , " Enter Name " , " Enter the name of your private chain " , QLineEdit : : Normal , QString ( " NewChain-%1 " ) . arg ( time ( 0 ) ) ) ;
if ( m_privateChain . isEmpty ( ) )
{
if ( ui - > usePrivate - > isChecked ( ) )
ui - > usePrivate - > setChecked ( false ) ;
else
// was cancelled.
return ;
}
bool ok ;
pc = QInputDialog : : getText ( this , " Enter Name " , " Enter the name of your private chain " , QLineEdit : : Normal , QString ( " NewChain-%1 " ) . arg ( time ( 0 ) ) , & ok ) ;
if ( ! ok )
return ;
}
else
m_privateChain . clear ( ) ;
on_killBlockchain_triggered ( ) ;
setPrivateChain ( pc ) ;
}
void Main : : on_vmInterpreter_triggered ( ) { VMFactory : : setKind ( VMKind : : Interpreter ) ; }
@ -2015,7 +2039,7 @@ void Main::on_net_triggered()
{
web3 ( ) - > setIdealPeerCount ( ui - > idealPeers - > value ( ) ) ;
web3 ( ) - > setNetworkPreferences ( netPrefs ( ) , ui - > dropPeers - > isChecked ( ) ) ;
ethereum ( ) - > setNetworkId ( m_privateChain . size ( ) ? sha3 ( m_privateChain . toStdString ( ) ) : h256 ( ) ) ;
ethereum ( ) - > setNetworkId ( ( h256 ) ( u256 ) ( int ) c_network ) ;
web3 ( ) - > startNetwork ( ) ;
ui - > downloadView - > setEthereum ( ethereum ( ) ) ;
ui - > enode - > setText ( QString : : fromStdString ( web3 ( ) - > enode ( ) ) ) ;