@ -378,10 +378,17 @@ NetworkPreferences Main::netPrefs() const
publicIP . clear ( ) ;
publicIP . clear ( ) ;
}
}
NetworkPreferences ret ;
if ( isPublicAddress ( publicIP ) )
if ( isPublicAddress ( publicIP ) )
return NetworkPreferences ( publicIP , listenIP , ui - > port - > value ( ) , ui - > upnp - > isChecked ( ) ) ;
ret = NetworkPreferences ( publicIP , listenIP , ui - > port - > value ( ) , ui - > upnp - > isChecked ( ) ) ;
else
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 ( )
void Main : : onKeysChanged ( )
@ -776,6 +783,30 @@ void Main::writeSettings()
s . setValue ( " windowState " , saveState ( ) ) ;
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
Secret Main : : retrieveSecret ( Address const & _address ) const
{
{
while ( true )
while ( true )
@ -852,8 +883,7 @@ void Main::readSettings(bool _skipGeometry)
ui - > listenIP - > setText ( s . value ( " listenIP " , " " ) . toString ( ) ) ;
ui - > listenIP - > setText ( s . value ( " listenIP " , " " ) . toString ( ) ) ;
ui - > port - > setValue ( s . value ( " port " , ui - > port - > value ( ) ) . toInt ( ) ) ;
ui - > port - > setValue ( s . value ( " port " , ui - > port - > value ( ) ) . toInt ( ) ) ;
ui - > nameReg - > setText ( s . value ( " nameReg " , " " ) . toString ( ) ) ;
ui - > nameReg - > setText ( s . value ( " nameReg " , " " ) . toString ( ) ) ;
m_privateChain = s . value ( " privateChain " , " " ) . toString ( ) ;
setPrivateChain ( s . value ( " privateChain " , " " ) . toString ( ) ) ;
ui - > usePrivate - > setChecked ( m_privateChain . size ( ) ) ;
ui - > verbosity - > setValue ( s . value ( " verbosity " , 1 ) . toInt ( ) ) ;
ui - > verbosity - > setValue ( s . value ( " verbosity " , 1 ) . toInt ( ) ) ;
# if ETH_EVMJIT // We care only if JIT is enabled. Otherwise it can cause misconfiguration.
# 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 ( )
void Main : : on_usePrivate_triggered ( )
{
{
QString pc ;
if ( ui - > usePrivate - > isChecked ( ) )
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 ) ) ) ;
bool ok ;
if ( m_privateChain . isEmpty ( ) )
pc = QInputDialog : : getText ( this , " Enter Name " , " Enter the name of your private chain " , QLineEdit : : Normal , QString ( " NewChain-%1 " ) . arg ( time ( 0 ) ) , & ok ) ;
{
if ( ! ok )
if ( ui - > usePrivate - > isChecked ( ) )
return ;
ui - > usePrivate - > setChecked ( false ) ;
else
// was cancelled.
return ;
}
}
}
else
setPrivateChain ( pc ) ;
m_privateChain . clear ( ) ;
on_killBlockchain_triggered ( ) ;
}
}
void Main : : on_vmInterpreter_triggered ( ) { VMFactory : : setKind ( VMKind : : Interpreter ) ; }
void Main : : on_vmInterpreter_triggered ( ) { VMFactory : : setKind ( VMKind : : Interpreter ) ; }
@ -2015,7 +2039,7 @@ void Main::on_net_triggered()
{
{
web3 ( ) - > setIdealPeerCount ( ui - > idealPeers - > value ( ) ) ;
web3 ( ) - > setIdealPeerCount ( ui - > idealPeers - > value ( ) ) ;
web3 ( ) - > setNetworkPreferences ( netPrefs ( ) , ui - > dropPeers - > isChecked ( ) ) ;
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 ( ) ;
web3 ( ) - > startNetwork ( ) ;
ui - > downloadView - > setEthereum ( ethereum ( ) ) ;
ui - > downloadView - > setEthereum ( ethereum ( ) ) ;
ui - > enode - > setText ( QString : : fromStdString ( web3 ( ) - > enode ( ) ) ) ;
ui - > enode - > setText ( QString : : fromStdString ( web3 ( ) - > enode ( ) ) ) ;