- fixes errors introduced in the earlier refactoring
- more variables moved to state.py
- path finding functions moved to paths.py
- remembers IPv6 network unreachable (in the future can be used to skip
IPv6 for a while)
print'(For msg message via API) Doing proof of work. Total required difficulty:',float(requiredAverageProofOfWorkNonceTrialsPerByte)/shared.networkDefaultProofOfWorkNonceTrialsPerByte,'Required small message difficulty:',float(requiredPayloadLengthExtraBytes)/shared.networkDefaultPayloadLengthExtraBytes
print'(For msg message via API) Doing proof of work. Total required difficulty:',float(requiredAverageProofOfWorkNonceTrialsPerByte)/protocol.networkDefaultProofOfWorkNonceTrialsPerByte,'Required small message difficulty:',float(requiredPayloadLengthExtraBytes)/protocol.networkDefaultPayloadLengthExtraBytes
"MainWindow","You may manage your keys by editing the keys.dat file stored in\n%1 \nIt is important that you back up this file.").arg(shared.appdata),QMessageBox.Ok)
"MainWindow","You may manage your keys by editing the keys.dat file stored in\n%1 \nIt is important that you back up this file.").arg(state.appdata),QMessageBox.Ok)
"MainWindow","You may manage your keys by editing the keys.dat file stored in the same directory as this program. It is important that you back up this file. Would you like to open the file now? (Be sure to close Bitmessage before making any changes.)"),QtGui.QMessageBox.Yes,QtGui.QMessageBox.No)
"MainWindow","You may manage your keys by editing the keys.dat file stored in\n%1 \nIt is important that you back up this file. Would you like to open the file now? (Be sure to close Bitmessage before making any changes.)").arg(shared.appdata),QtGui.QMessageBox.Yes,QtGui.QMessageBox.No)
"MainWindow","You may manage your keys by editing the keys.dat file stored in\n%1 \nIt is important that you back up this file. Would you like to open the file now? (Be sure to close Bitmessage before making any changes.)").arg(state.appdata),QtGui.QMessageBox.Yes,QtGui.QMessageBox.No)
ifreply==QtGui.QMessageBox.Yes:
shared.openKeysFile()
@ -2409,10 +2412,10 @@ class MyForm(settingsmixin.SMainWindow):
# It might now be possible to send msgs which were previously marked as toodifficult.
# Let us change them to 'msgqueued'. The singleWorker will try to send them and will again
@ -2493,21 +2496,21 @@ class MyForm(settingsmixin.SMainWindow):
# startup for linux
pass
ifshared.appdata!=shared.lookupExeFolder()andself.settingsDialogInstance.ui.checkBoxPortableMode.isChecked():# If we are NOT using portable mode now but the user selected that we should...
ifstate.appdata!=paths.lookupExeFolder()andself.settingsDialogInstance.ui.checkBoxPortableMode.isChecked():# If we are NOT using portable mode now but the user selected that we should...
# Write the keys.dat file to disk in the new location
@ -2515,25 +2518,25 @@ class MyForm(settingsmixin.SMainWindow):
except:
pass
ifshared.appdata==shared.lookupExeFolder()andnotself.settingsDialogInstance.ui.checkBoxPortableMode.isChecked():# If we ARE using portable mode now but the user selected that we shouldn't...
shared.appdata=shared.lookupAppdataFolder()
ifnotos.path.exists(shared.appdata):
os.makedirs(shared.appdata)
ifstate.appdata==paths.lookupExeFolder()andnotself.settingsDialogInstance.ui.checkBoxPortableMode.isChecked():# If we ARE using portable mode now but the user selected that we shouldn't...
state.appdata=paths.lookupAppdataFolder()
ifnotos.path.exists(state.appdata):
os.makedirs(state.appdata)
sqlStoredProcedure('movemessagstoappdata')
# Write the keys.dat file to disk in the new location
shared.writeKeysFile()
# Write the knownnodes.dat file to disk in the new location
@ -53,7 +54,7 @@ class singleCleaner(threading.Thread, StoppableThread):
Inventory().flush()
shared.UISignalQueue.put(('updateStatusBar',''))
shared.broadcastToSendDataQueues((
protocol.broadcastToSendDataQueues((
0,'pong','no data'))# commands the sendData threads to send out a pong message if they haven't sent anything else in the last five minutes. The socket timeout-time is 10 minutes.
# If we are running as a daemon then we are going to fill up the UI
# queue which will never be handled by a UI. We should clear it to
@ -98,7 +99,7 @@ class singleCleaner(threading.Thread, StoppableThread):
# Let us write out the knowNodes to disk if there is anything new to write out.
ifshared.needToWriteKnownNodesToDisk:
shared.knownNodesLock.acquire()
output=open(shared.appdata+'knownnodes.dat','wb')
output=open(state.appdata+'knownnodes.dat','wb')
try:
pickle.dump(shared.knownNodes,output)
output.close()
@ -116,7 +117,7 @@ class singleCleaner(threading.Thread, StoppableThread):
defresendPubkeyRequest(address):
logger.debug('It has been a long time and we haven\'t heard a response to our getpubkey request. Sending again.')
try:
del neededPubkeys[
delstate.neededPubkeys[
address]# We need to take this entry out of the neededPubkeys structure because the shared.workerQueue checks to see whether the entry is already present and will not do the POW and send the message because it assumes that it has already done it recently.
ifrequiredAverageProofOfWorkNonceTrialsPerByte<shared.networkDefaultProofOfWorkNonceTrialsPerByte:# We still have to meet a minimum POW difficulty regardless of what they say is allowed in order to get our message to propagate through the network.
ifrequiredAverageProofOfWorkNonceTrialsPerByte<protocol.networkDefaultProofOfWorkNonceTrialsPerByte:# We still have to meet a minimum POW difficulty regardless of what they say is allowed in order to get our message to propagate through the network.
logger.debug('Using averageProofOfWorkNonceTrialsPerByte: %s and payloadLengthExtraBytes: %s.'%(requiredAverageProofOfWorkNonceTrialsPerByte,requiredPayloadLengthExtraBytes))
shared.UISignalQueue.put(('updateSentItemStatusByAckdata',(ackdata,tr._translate("MainWindow","Doing work necessary to send message.\nReceiver\'s required difficulty: %1 and %2").arg(str(float(
# The demanded difficulty is more than we are willing
@ -684,8 +684,8 @@ class singleWorker(threading.Thread, StoppableThread):
sqlExecute(
'''UPDATE sent SET status='toodifficult' WHERE ackdata=? ''',
ackdata)
shared.UISignalQueue.put(('updateSentItemStatusByAckdata',(ackdata,tr._translate("MainWindow","Problem: The work demanded by the recipient (%1 and %2) is more difficult than you are willing to do. %3").arg(str(float(requiredAverageProofOfWorkNonceTrialsPerByte)/shared.networkDefaultProofOfWorkNonceTrialsPerByte)).arg(str(float(
shared.UISignalQueue.put(('updateSentItemStatusByAckdata',(ackdata,tr._translate("MainWindow","Problem: The work demanded by the recipient (%1 and %2) is more difficult than you are willing to do. %3").arg(str(float(requiredAverageProofOfWorkNonceTrialsPerByte)/protocol.networkDefaultProofOfWorkNonceTrialsPerByte)).arg(str(float(
storeConfigFilesInSameDirectoryAsProgramByDefault=False# The user may de-select Portable Mode in the settings if they want the config files to stay in the application data folder.
@ -25,31 +27,31 @@ def _loadTrustedPeer():
shared.trustedPeer=shared.Peer(host,int(port))
defloadConfig():
ifshared.appdata:
BMConfigParser().read(shared.appdata+'keys.dat')
#shared.appdata must have been specified as a startup option.
ifstate.appdata:
BMConfigParser().read(state.appdata+'keys.dat')
#state.appdata must have been specified as a startup option.