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) self.ui.labelNamecoinPassword.setEnabled(isNamecoind)
if isNamecoind: if isNamecoind:
self.ui.lineEditNamecoinPort.setText("8336") self.ui.lineEditNamecoinPort.setText(shared.namecoinDefaultRpcPort)
else: else:
self.ui.lineEditNamecoinPort.setText("9000") self.ui.lineEditNamecoinPort.setText("9000")

View File

@ -247,33 +247,34 @@ def ensureNamecoinOptions ():
hasPass = shared.config.has_option (configSection, "namecoinrpcpassword") hasPass = shared.config.has_option (configSection, "namecoinrpcpassword")
# Try to read user/password from .namecoin configuration file. # Try to read user/password from .namecoin configuration file.
if (not hasUser) or (not hasPass): try:
try: nmcFolder = lookupNamecoinFolder ()
nmcFolder = lookupNamecoinFolder () nmcConfig = nmcFolder + "namecoin.conf"
nmcConfig = nmcFolder + "namecoin.conf" nmc = open (nmcConfig, "r")
nmc = open (nmcConfig, "r")
while True: while True:
line = nmc.readline () line = nmc.readline ()
if line == "": if line == "":
break break
parts = line.split ("=") parts = line.split ("=")
if len (parts) == 2: if len (parts) == 2:
key = parts[0] key = parts[0]
val = parts[1].rstrip () val = parts[1].rstrip ()
if key == "rpcuser" and not hasUser: if key == "rpcuser" and not hasUser:
shared.config.set (configSection, shared.config.set (configSection,
"namecoinrpcuser", val) "namecoinrpcuser", val)
if key == "rpcpassword" and not hasPass: if key == "rpcpassword" and not hasPass:
shared.config.set (configSection, shared.config.set (configSection,
"namecoinrpcpassword", val) "namecoinrpcpassword", val)
if key == "rpcport":
nmc.close () shared.namecoinDefaultRpcPort = val
nmc.close ()
except Exception as exc: except Exception as exc:
print "Failure reading namecoin config file: %s" % str (exc) print "Failure reading namecoin config file: %s" % str (exc)
if (not hasUser): if (not hasUser):
shared.config.set (configSection, "namecoinrpcuser", "") shared.config.set (configSection, "namecoinrpcuser", "")
if (not hasPass): if (not hasPass):
shared.config.set (configSection, "namecoinrpcpassword", "") 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. 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. 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): def isInSqlInventory(hash):
t = (hash,) t = (hash,)
shared.sqlLock.acquire() shared.sqlLock.acquire()
@ -371,4 +376,4 @@ def fixSensitiveFilePermissions(filename, hasEnabledKeys):
raise raise
helper_startup.loadConfig() helper_startup.loadConfig()
from debug import logger from debug import logger