Read also rpcport from namecoin.conf.

Read also the rpcport setting from namecoin.conf when it is
available and use that as default when switching the setting
in the UI dialog.
This commit is contained in:
Daniel Kraft 2013-07-17 18:33:26 +02:00
parent a2fe6a1b44
commit 810387df3e
3 changed files with 35 additions and 29 deletions

View File

@ -2936,7 +2936,7 @@ class settingsDialog(QtGui.QDialog):
self.ui.labelNamecoinPassword.setEnabled(isNamecoind)
if isNamecoind:
self.ui.lineEditNamecoinPort.setText("8336")
self.ui.lineEditNamecoinPort.setText(shared.namecoinDefaultRpcPort)
else:
self.ui.lineEditNamecoinPort.setText("9000")

View File

@ -247,33 +247,34 @@ def ensureNamecoinOptions ():
hasPass = shared.config.has_option (configSection, "namecoinrpcpassword")
# Try to read user/password from .namecoin configuration file.
if (not hasUser) or (not hasPass):
try:
nmcFolder = lookupNamecoinFolder ()
nmcConfig = nmcFolder + "namecoin.conf"
nmc = open (nmcConfig, "r")
try:
nmcFolder = lookupNamecoinFolder ()
nmcConfig = nmcFolder + "namecoin.conf"
nmc = open (nmcConfig, "r")
while True:
line = nmc.readline ()
if line == "":
break
parts = line.split ("=")
if len (parts) == 2:
key = parts[0]
val = parts[1].rstrip ()
while True:
line = nmc.readline ()
if line == "":
break
parts = line.split ("=")
if len (parts) == 2:
key = parts[0]
val = parts[1].rstrip ()
if key == "rpcuser" and not hasUser:
shared.config.set (configSection,
"namecoinrpcuser", val)
if key == "rpcpassword" and not hasPass:
shared.config.set (configSection,
"namecoinrpcpassword", val)
nmc.close ()
if key == "rpcuser" and not hasUser:
shared.config.set (configSection,
"namecoinrpcuser", val)
if key == "rpcpassword" and not hasPass:
shared.config.set (configSection,
"namecoinrpcpassword", val)
if key == "rpcport":
shared.namecoinDefaultRpcPort = val
nmc.close ()
except Exception as exc:
print "Failure reading namecoin config file: %s" % str (exc)
if (not hasUser):
shared.config.set (configSection, "namecoinrpcuser", "")
if (not hasPass):
shared.config.set (configSection, "namecoinrpcpassword", "")
except Exception as exc:
print "Failure reading namecoin config file: %s" % str (exc)
if (not hasUser):
shared.config.set (configSection, "namecoinrpcuser", "")
if (not hasPass):
shared.config.set (configSection, "namecoinrpcpassword", "")

View File

@ -68,6 +68,11 @@ ackdataForWhichImWatching = {}
networkDefaultProofOfWorkNonceTrialsPerByte = 320 #The amount of work that should be performed (and demanded) per byte of the payload. Double this number to double the work.
networkDefaultPayloadLengthExtraBytes = 14000 #To make sending short messages a little more difficult, this value is added to the payload length for use in calculating the proof of work target.
# Remember here the RPC port read from namecoin.conf so we can restore to
# it as default whenever the user changes the "method" selection for
# namecoin integration to "namecoind".
namecoinDefaultRpcPort = "8336"
def isInSqlInventory(hash):
t = (hash,)
shared.sqlLock.acquire()
@ -371,4 +376,4 @@ def fixSensitiveFilePermissions(filename, hasEnabledKeys):
raise
helper_startup.loadConfig()
from debug import logger
from debug import logger