Cyclic import fix
- networkDefaultProofOfWorkNonceTrialsPerByte and networkDefaultPayloadLengthExtraBytes cyclic import fix - PyBitmessage should launch now when there's no keys.dat
This commit is contained in:
parent
2cc4435cfc
commit
157881bc63
19
src/api.py
19
src/api.py
|
@ -20,6 +20,7 @@ import shared
|
||||||
import time
|
import time
|
||||||
from addresses import decodeAddress,addBMIfNotPresent,decodeVarint,calculateInventoryHash,varintDecodeError
|
from addresses import decodeAddress,addBMIfNotPresent,decodeVarint,calculateInventoryHash,varintDecodeError
|
||||||
from configparser import BMConfigParser
|
from configparser import BMConfigParser
|
||||||
|
import defaults
|
||||||
import helper_inbox
|
import helper_inbox
|
||||||
import helper_sent
|
import helper_sent
|
||||||
import hashlib
|
import hashlib
|
||||||
|
@ -254,15 +255,15 @@ class MySimpleXMLRPCRequestHandler(SimpleXMLRPCRequestHandler):
|
||||||
elif len(params) == 3:
|
elif len(params) == 3:
|
||||||
label, eighteenByteRipe, totalDifficulty = params
|
label, eighteenByteRipe, totalDifficulty = params
|
||||||
nonceTrialsPerByte = int(
|
nonceTrialsPerByte = int(
|
||||||
protocol.networkDefaultProofOfWorkNonceTrialsPerByte * totalDifficulty)
|
defaults.networkDefaultProofOfWorkNonceTrialsPerByte * totalDifficulty)
|
||||||
payloadLengthExtraBytes = BMConfigParser().get(
|
payloadLengthExtraBytes = BMConfigParser().get(
|
||||||
'bitmessagesettings', 'defaultpayloadlengthextrabytes')
|
'bitmessagesettings', 'defaultpayloadlengthextrabytes')
|
||||||
elif len(params) == 4:
|
elif len(params) == 4:
|
||||||
label, eighteenByteRipe, totalDifficulty, smallMessageDifficulty = params
|
label, eighteenByteRipe, totalDifficulty, smallMessageDifficulty = params
|
||||||
nonceTrialsPerByte = int(
|
nonceTrialsPerByte = int(
|
||||||
protocol.networkDefaultProofOfWorkNonceTrialsPerByte * totalDifficulty)
|
defaults.networkDefaultProofOfWorkNonceTrialsPerByte * totalDifficulty)
|
||||||
payloadLengthExtraBytes = int(
|
payloadLengthExtraBytes = int(
|
||||||
protocol.networkDefaultPayloadLengthExtraBytes * smallMessageDifficulty)
|
defaults.networkDefaultPayloadLengthExtraBytes * smallMessageDifficulty)
|
||||||
else:
|
else:
|
||||||
raise APIError(0, 'Too many parameters!')
|
raise APIError(0, 'Too many parameters!')
|
||||||
label = self._decode(label, "base64")
|
label = self._decode(label, "base64")
|
||||||
|
@ -322,15 +323,15 @@ class MySimpleXMLRPCRequestHandler(SimpleXMLRPCRequestHandler):
|
||||||
elif len(params) == 6:
|
elif len(params) == 6:
|
||||||
passphrase, numberOfAddresses, addressVersionNumber, streamNumber, eighteenByteRipe, totalDifficulty = params
|
passphrase, numberOfAddresses, addressVersionNumber, streamNumber, eighteenByteRipe, totalDifficulty = params
|
||||||
nonceTrialsPerByte = int(
|
nonceTrialsPerByte = int(
|
||||||
protocol.networkDefaultProofOfWorkNonceTrialsPerByte * totalDifficulty)
|
defaults.networkDefaultProofOfWorkNonceTrialsPerByte * totalDifficulty)
|
||||||
payloadLengthExtraBytes = BMConfigParser().get(
|
payloadLengthExtraBytes = BMConfigParser().get(
|
||||||
'bitmessagesettings', 'defaultpayloadlengthextrabytes')
|
'bitmessagesettings', 'defaultpayloadlengthextrabytes')
|
||||||
elif len(params) == 7:
|
elif len(params) == 7:
|
||||||
passphrase, numberOfAddresses, addressVersionNumber, streamNumber, eighteenByteRipe, totalDifficulty, smallMessageDifficulty = params
|
passphrase, numberOfAddresses, addressVersionNumber, streamNumber, eighteenByteRipe, totalDifficulty, smallMessageDifficulty = params
|
||||||
nonceTrialsPerByte = int(
|
nonceTrialsPerByte = int(
|
||||||
protocol.networkDefaultProofOfWorkNonceTrialsPerByte * totalDifficulty)
|
defaults.networkDefaultProofOfWorkNonceTrialsPerByte * totalDifficulty)
|
||||||
payloadLengthExtraBytes = int(
|
payloadLengthExtraBytes = int(
|
||||||
protocol.networkDefaultPayloadLengthExtraBytes * smallMessageDifficulty)
|
defaults.networkDefaultPayloadLengthExtraBytes * smallMessageDifficulty)
|
||||||
else:
|
else:
|
||||||
raise APIError(0, 'Too many parameters!')
|
raise APIError(0, 'Too many parameters!')
|
||||||
if len(passphrase) == 0:
|
if len(passphrase) == 0:
|
||||||
|
@ -840,7 +841,7 @@ class MySimpleXMLRPCRequestHandler(SimpleXMLRPCRequestHandler):
|
||||||
# Let us do the POW and attach it to the front
|
# Let us do the POW and attach it to the front
|
||||||
target = 2**64 / ((len(encryptedPayload)+requiredPayloadLengthExtraBytes+8) * requiredAverageProofOfWorkNonceTrialsPerByte)
|
target = 2**64 / ((len(encryptedPayload)+requiredPayloadLengthExtraBytes+8) * requiredAverageProofOfWorkNonceTrialsPerByte)
|
||||||
with shared.printLock:
|
with shared.printLock:
|
||||||
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
|
print '(For msg message via API) Doing proof of work. Total required difficulty:', float(requiredAverageProofOfWorkNonceTrialsPerByte) / defaults.networkDefaultProofOfWorkNonceTrialsPerByte, 'Required small message difficulty:', float(requiredPayloadLengthExtraBytes) / defaults.networkDefaultPayloadLengthExtraBytes
|
||||||
powStartTime = time.time()
|
powStartTime = time.time()
|
||||||
initialHash = hashlib.sha512(encryptedPayload).digest()
|
initialHash = hashlib.sha512(encryptedPayload).digest()
|
||||||
trialValue, nonce = proofofwork.run(target, initialHash)
|
trialValue, nonce = proofofwork.run(target, initialHash)
|
||||||
|
@ -882,8 +883,8 @@ class MySimpleXMLRPCRequestHandler(SimpleXMLRPCRequestHandler):
|
||||||
payload = self._decode(payload, "hex")
|
payload = self._decode(payload, "hex")
|
||||||
|
|
||||||
# Let us do the POW
|
# Let us do the POW
|
||||||
target = 2 ** 64 / ((len(payload) + protocol.networkDefaultPayloadLengthExtraBytes +
|
target = 2 ** 64 / ((len(payload) + defaults.networkDefaultPayloadLengthExtraBytes +
|
||||||
8) * protocol.networkDefaultProofOfWorkNonceTrialsPerByte)
|
8) * defaults.networkDefaultProofOfWorkNonceTrialsPerByte)
|
||||||
print '(For pubkey message via API) Doing proof of work...'
|
print '(For pubkey message via API) Doing proof of work...'
|
||||||
initialHash = hashlib.sha512(payload).digest()
|
initialHash = hashlib.sha512(payload).digest()
|
||||||
trialValue, nonce = proofofwork.run(target, initialHash)
|
trialValue, nonce = proofofwork.run(target, initialHash)
|
||||||
|
|
|
@ -26,10 +26,10 @@ import time
|
||||||
from api import MySimpleXMLRPCRequestHandler, StoppableXMLRPCServer
|
from api import MySimpleXMLRPCRequestHandler, StoppableXMLRPCServer
|
||||||
from helper_startup import isOurOperatingSystemLimitedToHavingVeryFewHalfOpenConnections
|
from helper_startup import isOurOperatingSystemLimitedToHavingVeryFewHalfOpenConnections
|
||||||
|
|
||||||
|
import defaults
|
||||||
import shared
|
import shared
|
||||||
from helper_sql import sqlQuery
|
from helper_sql import sqlQuery
|
||||||
import state
|
import state
|
||||||
import protocol
|
|
||||||
import shutdown
|
import shutdown
|
||||||
import threading
|
import threading
|
||||||
|
|
||||||
|
@ -149,10 +149,10 @@ class singleAPI(threading.Thread, StoppableThread):
|
||||||
selfInitiatedConnections = {}
|
selfInitiatedConnections = {}
|
||||||
|
|
||||||
if shared.useVeryEasyProofOfWorkForTesting:
|
if shared.useVeryEasyProofOfWorkForTesting:
|
||||||
protocol.networkDefaultProofOfWorkNonceTrialsPerByte = int(
|
defaults.networkDefaultProofOfWorkNonceTrialsPerByte = int(
|
||||||
protocol.networkDefaultProofOfWorkNonceTrialsPerByte / 100)
|
defaults.networkDefaultProofOfWorkNonceTrialsPerByte / 100)
|
||||||
protocol.networkDefaultPayloadLengthExtraBytes = int(
|
defaults.networkDefaultPayloadLengthExtraBytes = int(
|
||||||
protocol.networkDefaultPayloadLengthExtraBytes / 100)
|
defaults.networkDefaultPayloadLengthExtraBytes / 100)
|
||||||
|
|
||||||
class Main:
|
class Main:
|
||||||
def start(self, daemon=False):
|
def start(self, daemon=False):
|
||||||
|
|
|
@ -31,6 +31,7 @@ from addresses import *
|
||||||
import shared
|
import shared
|
||||||
from bitmessageui import *
|
from bitmessageui import *
|
||||||
from configparser import BMConfigParser
|
from configparser import BMConfigParser
|
||||||
|
import defaults
|
||||||
from namecoin import namecoinConnection, ensureNamecoinOptions
|
from namecoin import namecoinConnection, ensureNamecoinOptions
|
||||||
from newaddressdialog import *
|
from newaddressdialog import *
|
||||||
from newaddresswizard import *
|
from newaddresswizard import *
|
||||||
|
@ -82,7 +83,6 @@ from inventory import PendingDownload, PendingUpload, PendingUploadDeadlineExcep
|
||||||
import knownnodes
|
import knownnodes
|
||||||
import paths
|
import paths
|
||||||
from proofofwork import getPowType
|
from proofofwork import getPowType
|
||||||
import protocol
|
|
||||||
import queues
|
import queues
|
||||||
import shutdown
|
import shutdown
|
||||||
import state
|
import state
|
||||||
|
@ -2417,10 +2417,10 @@ class MyForm(settingsmixin.SMainWindow):
|
||||||
# Demanded difficulty tab
|
# Demanded difficulty tab
|
||||||
if float(self.settingsDialogInstance.ui.lineEditTotalDifficulty.text()) >= 1:
|
if float(self.settingsDialogInstance.ui.lineEditTotalDifficulty.text()) >= 1:
|
||||||
BMConfigParser().set('bitmessagesettings', 'defaultnoncetrialsperbyte', str(int(float(
|
BMConfigParser().set('bitmessagesettings', 'defaultnoncetrialsperbyte', str(int(float(
|
||||||
self.settingsDialogInstance.ui.lineEditTotalDifficulty.text()) * protocol.networkDefaultProofOfWorkNonceTrialsPerByte)))
|
self.settingsDialogInstance.ui.lineEditTotalDifficulty.text()) * defaults.networkDefaultProofOfWorkNonceTrialsPerByte)))
|
||||||
if float(self.settingsDialogInstance.ui.lineEditSmallMessageDifficulty.text()) >= 1:
|
if float(self.settingsDialogInstance.ui.lineEditSmallMessageDifficulty.text()) >= 1:
|
||||||
BMConfigParser().set('bitmessagesettings', 'defaultpayloadlengthextrabytes', str(int(float(
|
BMConfigParser().set('bitmessagesettings', 'defaultpayloadlengthextrabytes', str(int(float(
|
||||||
self.settingsDialogInstance.ui.lineEditSmallMessageDifficulty.text()) * protocol.networkDefaultPayloadLengthExtraBytes)))
|
self.settingsDialogInstance.ui.lineEditSmallMessageDifficulty.text()) * defaults.networkDefaultPayloadLengthExtraBytes)))
|
||||||
|
|
||||||
if self.settingsDialogInstance.ui.comboBoxOpenCL.currentText().toUtf8() != BMConfigParser().safeGet("bitmessagesettings", "opencl"):
|
if self.settingsDialogInstance.ui.comboBoxOpenCL.currentText().toUtf8() != BMConfigParser().safeGet("bitmessagesettings", "opencl"):
|
||||||
BMConfigParser().set('bitmessagesettings', 'opencl', str(self.settingsDialogInstance.ui.comboBoxOpenCL.currentText()))
|
BMConfigParser().set('bitmessagesettings', 'opencl', str(self.settingsDialogInstance.ui.comboBoxOpenCL.currentText()))
|
||||||
|
@ -2429,18 +2429,18 @@ class MyForm(settingsmixin.SMainWindow):
|
||||||
|
|
||||||
if float(self.settingsDialogInstance.ui.lineEditMaxAcceptableTotalDifficulty.text()) >= 1 or float(self.settingsDialogInstance.ui.lineEditMaxAcceptableTotalDifficulty.text()) == 0:
|
if float(self.settingsDialogInstance.ui.lineEditMaxAcceptableTotalDifficulty.text()) >= 1 or float(self.settingsDialogInstance.ui.lineEditMaxAcceptableTotalDifficulty.text()) == 0:
|
||||||
if BMConfigParser().get('bitmessagesettings','maxacceptablenoncetrialsperbyte') != str(int(float(
|
if BMConfigParser().get('bitmessagesettings','maxacceptablenoncetrialsperbyte') != str(int(float(
|
||||||
self.settingsDialogInstance.ui.lineEditMaxAcceptableTotalDifficulty.text()) * protocol.networkDefaultProofOfWorkNonceTrialsPerByte)):
|
self.settingsDialogInstance.ui.lineEditMaxAcceptableTotalDifficulty.text()) * defaults.networkDefaultProofOfWorkNonceTrialsPerByte)):
|
||||||
# the user changed the max acceptable total difficulty
|
# the user changed the max acceptable total difficulty
|
||||||
acceptableDifficultyChanged = True
|
acceptableDifficultyChanged = True
|
||||||
BMConfigParser().set('bitmessagesettings', 'maxacceptablenoncetrialsperbyte', str(int(float(
|
BMConfigParser().set('bitmessagesettings', 'maxacceptablenoncetrialsperbyte', str(int(float(
|
||||||
self.settingsDialogInstance.ui.lineEditMaxAcceptableTotalDifficulty.text()) * protocol.networkDefaultProofOfWorkNonceTrialsPerByte)))
|
self.settingsDialogInstance.ui.lineEditMaxAcceptableTotalDifficulty.text()) * defaults.networkDefaultProofOfWorkNonceTrialsPerByte)))
|
||||||
if float(self.settingsDialogInstance.ui.lineEditMaxAcceptableSmallMessageDifficulty.text()) >= 1 or float(self.settingsDialogInstance.ui.lineEditMaxAcceptableSmallMessageDifficulty.text()) == 0:
|
if float(self.settingsDialogInstance.ui.lineEditMaxAcceptableSmallMessageDifficulty.text()) >= 1 or float(self.settingsDialogInstance.ui.lineEditMaxAcceptableSmallMessageDifficulty.text()) == 0:
|
||||||
if BMConfigParser().get('bitmessagesettings','maxacceptablepayloadlengthextrabytes') != str(int(float(
|
if BMConfigParser().get('bitmessagesettings','maxacceptablepayloadlengthextrabytes') != str(int(float(
|
||||||
self.settingsDialogInstance.ui.lineEditMaxAcceptableSmallMessageDifficulty.text()) * protocol.networkDefaultPayloadLengthExtraBytes)):
|
self.settingsDialogInstance.ui.lineEditMaxAcceptableSmallMessageDifficulty.text()) * defaults.networkDefaultPayloadLengthExtraBytes)):
|
||||||
# the user changed the max acceptable small message difficulty
|
# the user changed the max acceptable small message difficulty
|
||||||
acceptableDifficultyChanged = True
|
acceptableDifficultyChanged = True
|
||||||
BMConfigParser().set('bitmessagesettings', 'maxacceptablepayloadlengthextrabytes', str(int(float(
|
BMConfigParser().set('bitmessagesettings', 'maxacceptablepayloadlengthextrabytes', str(int(float(
|
||||||
self.settingsDialogInstance.ui.lineEditMaxAcceptableSmallMessageDifficulty.text()) * protocol.networkDefaultPayloadLengthExtraBytes)))
|
self.settingsDialogInstance.ui.lineEditMaxAcceptableSmallMessageDifficulty.text()) * defaults.networkDefaultPayloadLengthExtraBytes)))
|
||||||
if acceptableDifficultyChanged:
|
if acceptableDifficultyChanged:
|
||||||
# It might now be possible to send msgs which were previously marked as toodifficult.
|
# 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
|
# Let us change them to 'msgqueued'. The singleWorker will try to send them and will again
|
||||||
|
@ -4112,15 +4112,15 @@ class settingsDialog(QtGui.QDialog):
|
||||||
|
|
||||||
# Demanded difficulty tab
|
# Demanded difficulty tab
|
||||||
self.ui.lineEditTotalDifficulty.setText(str((float(BMConfigParser().getint(
|
self.ui.lineEditTotalDifficulty.setText(str((float(BMConfigParser().getint(
|
||||||
'bitmessagesettings', 'defaultnoncetrialsperbyte')) / protocol.networkDefaultProofOfWorkNonceTrialsPerByte)))
|
'bitmessagesettings', 'defaultnoncetrialsperbyte')) / defaults.networkDefaultProofOfWorkNonceTrialsPerByte)))
|
||||||
self.ui.lineEditSmallMessageDifficulty.setText(str((float(BMConfigParser().getint(
|
self.ui.lineEditSmallMessageDifficulty.setText(str((float(BMConfigParser().getint(
|
||||||
'bitmessagesettings', 'defaultpayloadlengthextrabytes')) / protocol.networkDefaultPayloadLengthExtraBytes)))
|
'bitmessagesettings', 'defaultpayloadlengthextrabytes')) / defaults.networkDefaultPayloadLengthExtraBytes)))
|
||||||
|
|
||||||
# Max acceptable difficulty tab
|
# Max acceptable difficulty tab
|
||||||
self.ui.lineEditMaxAcceptableTotalDifficulty.setText(str((float(BMConfigParser().getint(
|
self.ui.lineEditMaxAcceptableTotalDifficulty.setText(str((float(BMConfigParser().getint(
|
||||||
'bitmessagesettings', 'maxacceptablenoncetrialsperbyte')) / protocol.networkDefaultProofOfWorkNonceTrialsPerByte)))
|
'bitmessagesettings', 'maxacceptablenoncetrialsperbyte')) / defaults.networkDefaultProofOfWorkNonceTrialsPerByte)))
|
||||||
self.ui.lineEditMaxAcceptableSmallMessageDifficulty.setText(str((float(BMConfigParser().getint(
|
self.ui.lineEditMaxAcceptableSmallMessageDifficulty.setText(str((float(BMConfigParser().getint(
|
||||||
'bitmessagesettings', 'maxacceptablepayloadlengthextrabytes')) / protocol.networkDefaultPayloadLengthExtraBytes)))
|
'bitmessagesettings', 'maxacceptablepayloadlengthextrabytes')) / defaults.networkDefaultPayloadLengthExtraBytes)))
|
||||||
|
|
||||||
# OpenCL
|
# OpenCL
|
||||||
if openclpow.openclAvailable():
|
if openclpow.openclAvailable():
|
||||||
|
|
|
@ -7,13 +7,13 @@ import time
|
||||||
import account
|
import account
|
||||||
from configparser import BMConfigParser
|
from configparser import BMConfigParser
|
||||||
from debug import logger
|
from debug import logger
|
||||||
|
import defaults
|
||||||
from foldertree import AccountMixin
|
from foldertree import AccountMixin
|
||||||
from helper_sql import *
|
from helper_sql import *
|
||||||
from l10n import getTranslationLanguage
|
from l10n import getTranslationLanguage
|
||||||
from openclpow import openclAvailable, openclEnabled
|
from openclpow import openclAvailable, openclEnabled
|
||||||
import paths
|
import paths
|
||||||
from proofofwork import bmpow
|
from proofofwork import bmpow
|
||||||
import protocol
|
|
||||||
from pyelliptic.openssl import OpenSSL
|
from pyelliptic.openssl import OpenSSL
|
||||||
import queues
|
import queues
|
||||||
import shared
|
import shared
|
||||||
|
@ -67,7 +67,7 @@ def checkHasNormalAddress():
|
||||||
|
|
||||||
def createAddressIfNeeded(myapp):
|
def createAddressIfNeeded(myapp):
|
||||||
if not checkHasNormalAddress():
|
if not checkHasNormalAddress():
|
||||||
queues.addressGeneratorQueue.put(('createRandomAddress', 4, 1, str(QtGui.QApplication.translate("Support", SUPPORT_MY_LABEL)), 1, "", False, protocol.networkDefaultProofOfWorkNonceTrialsPerByte, protocol.networkDefaultPayloadLengthExtraBytes))
|
queues.addressGeneratorQueue.put(('createRandomAddress', 4, 1, str(QtGui.QApplication.translate("Support", SUPPORT_MY_LABEL)), 1, "", False, defaults.networkDefaultProofOfWorkNonceTrialsPerByte, defaults.networkDefaultPayloadLengthExtraBytes))
|
||||||
while state.shutdown == 0 and not checkHasNormalAddress():
|
while state.shutdown == 0 and not checkHasNormalAddress():
|
||||||
time.sleep(.2)
|
time.sleep(.2)
|
||||||
myapp.rerenderComboBoxSendFrom()
|
myapp.rerenderComboBoxSendFrom()
|
||||||
|
|
|
@ -9,8 +9,8 @@ import highlevelcrypto
|
||||||
from addresses import *
|
from addresses import *
|
||||||
from configparser import BMConfigParser
|
from configparser import BMConfigParser
|
||||||
from debug import logger
|
from debug import logger
|
||||||
|
import defaults
|
||||||
from helper_threading import *
|
from helper_threading import *
|
||||||
import protocol
|
|
||||||
from pyelliptic import arithmetic
|
from pyelliptic import arithmetic
|
||||||
import tr
|
import tr
|
||||||
from binascii import hexlify
|
from binascii import hexlify
|
||||||
|
@ -80,13 +80,13 @@ class addressGenerator(threading.Thread, StoppableThread):
|
||||||
if nonceTrialsPerByte == 0:
|
if nonceTrialsPerByte == 0:
|
||||||
nonceTrialsPerByte = BMConfigParser().getint(
|
nonceTrialsPerByte = BMConfigParser().getint(
|
||||||
'bitmessagesettings', 'defaultnoncetrialsperbyte')
|
'bitmessagesettings', 'defaultnoncetrialsperbyte')
|
||||||
if nonceTrialsPerByte < protocol.networkDefaultProofOfWorkNonceTrialsPerByte:
|
if nonceTrialsPerByte < defaults.networkDefaultProofOfWorkNonceTrialsPerByte:
|
||||||
nonceTrialsPerByte = protocol.networkDefaultProofOfWorkNonceTrialsPerByte
|
nonceTrialsPerByte = defaults.networkDefaultProofOfWorkNonceTrialsPerByte
|
||||||
if payloadLengthExtraBytes == 0:
|
if payloadLengthExtraBytes == 0:
|
||||||
payloadLengthExtraBytes = BMConfigParser().getint(
|
payloadLengthExtraBytes = BMConfigParser().getint(
|
||||||
'bitmessagesettings', 'defaultpayloadlengthextrabytes')
|
'bitmessagesettings', 'defaultpayloadlengthextrabytes')
|
||||||
if payloadLengthExtraBytes < protocol.networkDefaultPayloadLengthExtraBytes:
|
if payloadLengthExtraBytes < defaults.networkDefaultPayloadLengthExtraBytes:
|
||||||
payloadLengthExtraBytes = protocol.networkDefaultPayloadLengthExtraBytes
|
payloadLengthExtraBytes = defaults.networkDefaultPayloadLengthExtraBytes
|
||||||
if command == 'createRandomAddress':
|
if command == 'createRandomAddress':
|
||||||
queues.UISignalQueue.put((
|
queues.UISignalQueue.put((
|
||||||
'updateStatusBar', tr._translate("MainWindow", "Generating one new address")))
|
'updateStatusBar', tr._translate("MainWindow", "Generating one new address")))
|
||||||
|
|
|
@ -13,6 +13,7 @@ import sys
|
||||||
import tr
|
import tr
|
||||||
from configparser import BMConfigParser
|
from configparser import BMConfigParser
|
||||||
from debug import logger
|
from debug import logger
|
||||||
|
import defaults
|
||||||
from helper_sql import *
|
from helper_sql import *
|
||||||
import helper_inbox
|
import helper_inbox
|
||||||
from helper_generic import addDataPadding
|
from helper_generic import addDataPadding
|
||||||
|
@ -166,7 +167,7 @@ class singleWorker(threading.Thread, StoppableThread):
|
||||||
payload += pubEncryptionKey[1:]
|
payload += pubEncryptionKey[1:]
|
||||||
|
|
||||||
# Do the POW for this pubkey message
|
# Do the POW for this pubkey message
|
||||||
target = 2 ** 64 / (protocol.networkDefaultProofOfWorkNonceTrialsPerByte*(len(payload) + 8 + protocol.networkDefaultPayloadLengthExtraBytes + ((TTL*(len(payload)+8+protocol.networkDefaultPayloadLengthExtraBytes))/(2 ** 16))))
|
target = 2 ** 64 / (defaults.networkDefaultProofOfWorkNonceTrialsPerByte*(len(payload) + 8 + defaults.networkDefaultPayloadLengthExtraBytes + ((TTL*(len(payload)+8+defaults.networkDefaultPayloadLengthExtraBytes))/(2 ** 16))))
|
||||||
logger.info('(For pubkey message) Doing proof of work...')
|
logger.info('(For pubkey message) Doing proof of work...')
|
||||||
initialHash = hashlib.sha512(payload).digest()
|
initialHash = hashlib.sha512(payload).digest()
|
||||||
trialValue, nonce = proofofwork.run(target, initialHash)
|
trialValue, nonce = proofofwork.run(target, initialHash)
|
||||||
|
@ -257,7 +258,7 @@ class singleWorker(threading.Thread, StoppableThread):
|
||||||
payload += signature
|
payload += signature
|
||||||
|
|
||||||
# Do the POW for this pubkey message
|
# Do the POW for this pubkey message
|
||||||
target = 2 ** 64 / (protocol.networkDefaultProofOfWorkNonceTrialsPerByte*(len(payload) + 8 + protocol.networkDefaultPayloadLengthExtraBytes + ((TTL*(len(payload)+8+protocol.networkDefaultPayloadLengthExtraBytes))/(2 ** 16))))
|
target = 2 ** 64 / (defaults.networkDefaultProofOfWorkNonceTrialsPerByte*(len(payload) + 8 + defaults.networkDefaultPayloadLengthExtraBytes + ((TTL*(len(payload)+8+defaults.networkDefaultPayloadLengthExtraBytes))/(2 ** 16))))
|
||||||
logger.info('(For pubkey message) Doing proof of work...')
|
logger.info('(For pubkey message) Doing proof of work...')
|
||||||
initialHash = hashlib.sha512(payload).digest()
|
initialHash = hashlib.sha512(payload).digest()
|
||||||
trialValue, nonce = proofofwork.run(target, initialHash)
|
trialValue, nonce = proofofwork.run(target, initialHash)
|
||||||
|
@ -348,7 +349,7 @@ class singleWorker(threading.Thread, StoppableThread):
|
||||||
dataToEncrypt, hexlify(pubEncryptionKey))
|
dataToEncrypt, hexlify(pubEncryptionKey))
|
||||||
|
|
||||||
# Do the POW for this pubkey message
|
# Do the POW for this pubkey message
|
||||||
target = 2 ** 64 / (protocol.networkDefaultProofOfWorkNonceTrialsPerByte*(len(payload) + 8 + protocol.networkDefaultPayloadLengthExtraBytes + ((TTL*(len(payload)+8+protocol.networkDefaultPayloadLengthExtraBytes))/(2 ** 16))))
|
target = 2 ** 64 / (defaults.networkDefaultProofOfWorkNonceTrialsPerByte*(len(payload) + 8 + defaults.networkDefaultPayloadLengthExtraBytes + ((TTL*(len(payload)+8+defaults.networkDefaultPayloadLengthExtraBytes))/(2 ** 16))))
|
||||||
logger.info('(For pubkey message) Doing proof of work...')
|
logger.info('(For pubkey message) Doing proof of work...')
|
||||||
initialHash = hashlib.sha512(payload).digest()
|
initialHash = hashlib.sha512(payload).digest()
|
||||||
trialValue, nonce = proofofwork.run(target, initialHash)
|
trialValue, nonce = proofofwork.run(target, initialHash)
|
||||||
|
@ -470,7 +471,7 @@ class singleWorker(threading.Thread, StoppableThread):
|
||||||
payload += highlevelcrypto.encrypt(
|
payload += highlevelcrypto.encrypt(
|
||||||
dataToEncrypt, hexlify(pubEncryptionKey))
|
dataToEncrypt, hexlify(pubEncryptionKey))
|
||||||
|
|
||||||
target = 2 ** 64 / (protocol.networkDefaultProofOfWorkNonceTrialsPerByte*(len(payload) + 8 + protocol.networkDefaultPayloadLengthExtraBytes + ((TTL*(len(payload)+8+protocol.networkDefaultPayloadLengthExtraBytes))/(2 ** 16))))
|
target = 2 ** 64 / (defaults.networkDefaultProofOfWorkNonceTrialsPerByte*(len(payload) + 8 + defaults.networkDefaultPayloadLengthExtraBytes + ((TTL*(len(payload)+8+defaults.networkDefaultPayloadLengthExtraBytes))/(2 ** 16))))
|
||||||
logger.info('(For broadcast message) Doing proof of work...')
|
logger.info('(For broadcast message) Doing proof of work...')
|
||||||
queues.UISignalQueue.put(('updateSentItemStatusByAckdata', (
|
queues.UISignalQueue.put(('updateSentItemStatusByAckdata', (
|
||||||
ackdata, tr._translate("MainWindow", "Doing work necessary to send broadcast..."))))
|
ackdata, tr._translate("MainWindow", "Doing work necessary to send broadcast..."))))
|
||||||
|
@ -664,8 +665,8 @@ class singleWorker(threading.Thread, StoppableThread):
|
||||||
|
|
||||||
# Let us fetch the amount of work required by the recipient.
|
# Let us fetch the amount of work required by the recipient.
|
||||||
if toAddressVersionNumber == 2:
|
if toAddressVersionNumber == 2:
|
||||||
requiredAverageProofOfWorkNonceTrialsPerByte = protocol.networkDefaultProofOfWorkNonceTrialsPerByte
|
requiredAverageProofOfWorkNonceTrialsPerByte = defaults.networkDefaultProofOfWorkNonceTrialsPerByte
|
||||||
requiredPayloadLengthExtraBytes = protocol.networkDefaultPayloadLengthExtraBytes
|
requiredPayloadLengthExtraBytes = defaults.networkDefaultPayloadLengthExtraBytes
|
||||||
queues.UISignalQueue.put(('updateSentItemStatusByAckdata', (
|
queues.UISignalQueue.put(('updateSentItemStatusByAckdata', (
|
||||||
ackdata, tr._translate("MainWindow", "Doing work necessary to send message.\nThere is no required difficulty for version 2 addresses like this."))))
|
ackdata, tr._translate("MainWindow", "Doing work necessary to send message.\nThere is no required difficulty for version 2 addresses like this."))))
|
||||||
elif toAddressVersionNumber >= 3:
|
elif toAddressVersionNumber >= 3:
|
||||||
|
@ -675,13 +676,13 @@ class singleWorker(threading.Thread, StoppableThread):
|
||||||
requiredPayloadLengthExtraBytes, varintLength = decodeVarint(
|
requiredPayloadLengthExtraBytes, varintLength = decodeVarint(
|
||||||
pubkeyPayload[readPosition:readPosition + 10])
|
pubkeyPayload[readPosition:readPosition + 10])
|
||||||
readPosition += varintLength
|
readPosition += varintLength
|
||||||
if requiredAverageProofOfWorkNonceTrialsPerByte < 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.
|
if requiredAverageProofOfWorkNonceTrialsPerByte < defaults.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.
|
||||||
requiredAverageProofOfWorkNonceTrialsPerByte = protocol.networkDefaultProofOfWorkNonceTrialsPerByte
|
requiredAverageProofOfWorkNonceTrialsPerByte = defaults.networkDefaultProofOfWorkNonceTrialsPerByte
|
||||||
if requiredPayloadLengthExtraBytes < protocol.networkDefaultPayloadLengthExtraBytes:
|
if requiredPayloadLengthExtraBytes < defaults.networkDefaultPayloadLengthExtraBytes:
|
||||||
requiredPayloadLengthExtraBytes = protocol.networkDefaultPayloadLengthExtraBytes
|
requiredPayloadLengthExtraBytes = defaults.networkDefaultPayloadLengthExtraBytes
|
||||||
logger.debug('Using averageProofOfWorkNonceTrialsPerByte: %s and payloadLengthExtraBytes: %s.' % (requiredAverageProofOfWorkNonceTrialsPerByte, requiredPayloadLengthExtraBytes))
|
logger.debug('Using averageProofOfWorkNonceTrialsPerByte: %s and payloadLengthExtraBytes: %s.' % (requiredAverageProofOfWorkNonceTrialsPerByte, requiredPayloadLengthExtraBytes))
|
||||||
queues.UISignalQueue.put(('updateSentItemStatusByAckdata', (ackdata, tr._translate("MainWindow", "Doing work necessary to send message.\nReceiver\'s required difficulty: %1 and %2").arg(str(float(
|
queues.UISignalQueue.put(('updateSentItemStatusByAckdata', (ackdata, tr._translate("MainWindow", "Doing work necessary to send message.\nReceiver\'s required difficulty: %1 and %2").arg(str(float(
|
||||||
requiredAverageProofOfWorkNonceTrialsPerByte) / protocol.networkDefaultProofOfWorkNonceTrialsPerByte)).arg(str(float(requiredPayloadLengthExtraBytes) / protocol.networkDefaultPayloadLengthExtraBytes)))))
|
requiredAverageProofOfWorkNonceTrialsPerByte) / defaults.networkDefaultProofOfWorkNonceTrialsPerByte)).arg(str(float(requiredPayloadLengthExtraBytes) / defaults.networkDefaultPayloadLengthExtraBytes)))))
|
||||||
if status != 'forcepow':
|
if status != 'forcepow':
|
||||||
if (requiredAverageProofOfWorkNonceTrialsPerByte > BMConfigParser().getint('bitmessagesettings', 'maxacceptablenoncetrialsperbyte') and BMConfigParser().getint('bitmessagesettings', 'maxacceptablenoncetrialsperbyte') != 0) or (requiredPayloadLengthExtraBytes > BMConfigParser().getint('bitmessagesettings', 'maxacceptablepayloadlengthextrabytes') and BMConfigParser().getint('bitmessagesettings', 'maxacceptablepayloadlengthextrabytes') != 0):
|
if (requiredAverageProofOfWorkNonceTrialsPerByte > BMConfigParser().getint('bitmessagesettings', 'maxacceptablenoncetrialsperbyte') and BMConfigParser().getint('bitmessagesettings', 'maxacceptablenoncetrialsperbyte') != 0) or (requiredPayloadLengthExtraBytes > BMConfigParser().getint('bitmessagesettings', 'maxacceptablepayloadlengthextrabytes') and BMConfigParser().getint('bitmessagesettings', 'maxacceptablepayloadlengthextrabytes') != 0):
|
||||||
# The demanded difficulty is more than we are willing
|
# The demanded difficulty is more than we are willing
|
||||||
|
@ -689,8 +690,8 @@ class singleWorker(threading.Thread, StoppableThread):
|
||||||
sqlExecute(
|
sqlExecute(
|
||||||
'''UPDATE sent SET status='toodifficult' WHERE ackdata=? ''',
|
'''UPDATE sent SET status='toodifficult' WHERE ackdata=? ''',
|
||||||
ackdata)
|
ackdata)
|
||||||
queues.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(
|
queues.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) / defaults.networkDefaultProofOfWorkNonceTrialsPerByte)).arg(str(float(
|
||||||
requiredPayloadLengthExtraBytes) / protocol.networkDefaultPayloadLengthExtraBytes)).arg(l10n.formatTimestamp()))))
|
requiredPayloadLengthExtraBytes) / defaults.networkDefaultPayloadLengthExtraBytes)).arg(l10n.formatTimestamp()))))
|
||||||
continue
|
continue
|
||||||
else: # if we are sending a message to ourselves or a chan..
|
else: # if we are sending a message to ourselves or a chan..
|
||||||
logger.info('Sending a message.')
|
logger.info('Sending a message.')
|
||||||
|
@ -708,8 +709,8 @@ class singleWorker(threading.Thread, StoppableThread):
|
||||||
privEncryptionKeyBase58))
|
privEncryptionKeyBase58))
|
||||||
pubEncryptionKeyBase256 = unhexlify(highlevelcrypto.privToPub(
|
pubEncryptionKeyBase256 = unhexlify(highlevelcrypto.privToPub(
|
||||||
privEncryptionKeyHex))[1:]
|
privEncryptionKeyHex))[1:]
|
||||||
requiredAverageProofOfWorkNonceTrialsPerByte = protocol.networkDefaultProofOfWorkNonceTrialsPerByte
|
requiredAverageProofOfWorkNonceTrialsPerByte = defaults.networkDefaultProofOfWorkNonceTrialsPerByte
|
||||||
requiredPayloadLengthExtraBytes = protocol.networkDefaultPayloadLengthExtraBytes
|
requiredPayloadLengthExtraBytes = defaults.networkDefaultPayloadLengthExtraBytes
|
||||||
queues.UISignalQueue.put(('updateSentItemStatusByAckdata', (
|
queues.UISignalQueue.put(('updateSentItemStatusByAckdata', (
|
||||||
ackdata, tr._translate("MainWindow", "Doing work necessary to send message."))))
|
ackdata, tr._translate("MainWindow", "Doing work necessary to send message."))))
|
||||||
|
|
||||||
|
@ -751,9 +752,9 @@ class singleWorker(threading.Thread, StoppableThread):
|
||||||
# the receiver is in any of those lists.
|
# the receiver is in any of those lists.
|
||||||
if shared.isAddressInMyAddressBookSubscriptionsListOrWhitelist(toaddress):
|
if shared.isAddressInMyAddressBookSubscriptionsListOrWhitelist(toaddress):
|
||||||
payload += encodeVarint(
|
payload += encodeVarint(
|
||||||
protocol.networkDefaultProofOfWorkNonceTrialsPerByte)
|
defaults.networkDefaultProofOfWorkNonceTrialsPerByte)
|
||||||
payload += encodeVarint(
|
payload += encodeVarint(
|
||||||
protocol.networkDefaultPayloadLengthExtraBytes)
|
defaults.networkDefaultPayloadLengthExtraBytes)
|
||||||
else:
|
else:
|
||||||
payload += encodeVarint(BMConfigParser().getint(
|
payload += encodeVarint(BMConfigParser().getint(
|
||||||
fromaddress, 'noncetrialsperbyte'))
|
fromaddress, 'noncetrialsperbyte'))
|
||||||
|
@ -794,7 +795,7 @@ class singleWorker(threading.Thread, StoppableThread):
|
||||||
encryptedPayload += encodeVarint(1) # msg version
|
encryptedPayload += encodeVarint(1) # msg version
|
||||||
encryptedPayload += encodeVarint(toStreamNumber) + encrypted
|
encryptedPayload += encodeVarint(toStreamNumber) + encrypted
|
||||||
target = 2 ** 64 / (requiredAverageProofOfWorkNonceTrialsPerByte*(len(encryptedPayload) + 8 + requiredPayloadLengthExtraBytes + ((TTL*(len(encryptedPayload)+8+requiredPayloadLengthExtraBytes))/(2 ** 16))))
|
target = 2 ** 64 / (requiredAverageProofOfWorkNonceTrialsPerByte*(len(encryptedPayload) + 8 + requiredPayloadLengthExtraBytes + ((TTL*(len(encryptedPayload)+8+requiredPayloadLengthExtraBytes))/(2 ** 16))))
|
||||||
logger.info('(For msg message) Doing proof of work. Total required difficulty: %f. Required small message difficulty: %f.', float(requiredAverageProofOfWorkNonceTrialsPerByte) / protocol.networkDefaultProofOfWorkNonceTrialsPerByte, float(requiredPayloadLengthExtraBytes) / protocol.networkDefaultPayloadLengthExtraBytes)
|
logger.info('(For msg message) Doing proof of work. Total required difficulty: %f. Required small message difficulty: %f.', float(requiredAverageProofOfWorkNonceTrialsPerByte) / defaults.networkDefaultProofOfWorkNonceTrialsPerByte, float(requiredPayloadLengthExtraBytes) / defaults.networkDefaultPayloadLengthExtraBytes)
|
||||||
|
|
||||||
powStartTime = time.time()
|
powStartTime = time.time()
|
||||||
initialHash = hashlib.sha512(encryptedPayload).digest()
|
initialHash = hashlib.sha512(encryptedPayload).digest()
|
||||||
|
@ -918,7 +919,7 @@ class singleWorker(threading.Thread, StoppableThread):
|
||||||
queues.UISignalQueue.put(('updateSentItemStatusByToAddress', (
|
queues.UISignalQueue.put(('updateSentItemStatusByToAddress', (
|
||||||
toAddress, tr._translate("MainWindow",'Doing work necessary to request encryption key.'))))
|
toAddress, tr._translate("MainWindow",'Doing work necessary to request encryption key.'))))
|
||||||
|
|
||||||
target = 2 ** 64 / (protocol.networkDefaultProofOfWorkNonceTrialsPerByte*(len(payload) + 8 + protocol.networkDefaultPayloadLengthExtraBytes + ((TTL*(len(payload)+8+protocol.networkDefaultPayloadLengthExtraBytes))/(2 ** 16))))
|
target = 2 ** 64 / (defaults.networkDefaultProofOfWorkNonceTrialsPerByte*(len(payload) + 8 + defaults.networkDefaultPayloadLengthExtraBytes + ((TTL*(len(payload)+8+defaults.networkDefaultPayloadLengthExtraBytes))/(2 ** 16))))
|
||||||
initialHash = hashlib.sha512(payload).digest()
|
initialHash = hashlib.sha512(payload).digest()
|
||||||
trialValue, nonce = proofofwork.run(target, initialHash)
|
trialValue, nonce = proofofwork.run(target, initialHash)
|
||||||
logger.info('Found proof of work ' + str(trialValue) + ' Nonce: ' + str(nonce))
|
logger.info('Found proof of work ' + str(trialValue) + ' Nonce: ' + str(nonce))
|
||||||
|
@ -972,7 +973,7 @@ class singleWorker(threading.Thread, StoppableThread):
|
||||||
payload += encodeVarint(1) # msg version
|
payload += encodeVarint(1) # msg version
|
||||||
payload += encodeVarint(toStreamNumber) + ackdata
|
payload += encodeVarint(toStreamNumber) + ackdata
|
||||||
|
|
||||||
target = 2 ** 64 / (protocol.networkDefaultProofOfWorkNonceTrialsPerByte*(len(payload) + 8 + protocol.networkDefaultPayloadLengthExtraBytes + ((TTL*(len(payload)+8+protocol.networkDefaultPayloadLengthExtraBytes))/(2 ** 16))))
|
target = 2 ** 64 / (defaults.networkDefaultProofOfWorkNonceTrialsPerByte*(len(payload) + 8 + defaults.networkDefaultPayloadLengthExtraBytes + ((TTL*(len(payload)+8+defaults.networkDefaultPayloadLengthExtraBytes))/(2 ** 16))))
|
||||||
logger.info('(For ack message) Doing proof of work. TTL set to ' + str(TTL))
|
logger.info('(For ack message) Doing proof of work. TTL set to ' + str(TTL))
|
||||||
|
|
||||||
powStartTime = time.time()
|
powStartTime = time.time()
|
||||||
|
|
|
@ -10,7 +10,6 @@ import defaults
|
||||||
import helper_sql
|
import helper_sql
|
||||||
from namecoin import ensureNamecoinOptions
|
from namecoin import ensureNamecoinOptions
|
||||||
import paths
|
import paths
|
||||||
import protocol
|
|
||||||
import queues
|
import queues
|
||||||
import random
|
import random
|
||||||
import state
|
import state
|
||||||
|
@ -117,9 +116,9 @@ class sqlThread(threading.Thread):
|
||||||
|
|
||||||
if BMConfigParser().getint('bitmessagesettings', 'settingsversion') == 4:
|
if BMConfigParser().getint('bitmessagesettings', 'settingsversion') == 4:
|
||||||
BMConfigParser().set('bitmessagesettings', 'defaultnoncetrialsperbyte', str(
|
BMConfigParser().set('bitmessagesettings', 'defaultnoncetrialsperbyte', str(
|
||||||
protocol.networkDefaultProofOfWorkNonceTrialsPerByte))
|
defaults.networkDefaultProofOfWorkNonceTrialsPerByte))
|
||||||
BMConfigParser().set('bitmessagesettings', 'defaultpayloadlengthextrabytes', str(
|
BMConfigParser().set('bitmessagesettings', 'defaultpayloadlengthextrabytes', str(
|
||||||
protocol.networkDefaultPayloadLengthExtraBytes))
|
defaults.networkDefaultPayloadLengthExtraBytes))
|
||||||
BMConfigParser().set('bitmessagesettings', 'settingsversion', '5')
|
BMConfigParser().set('bitmessagesettings', 'settingsversion', '5')
|
||||||
|
|
||||||
if BMConfigParser().getint('bitmessagesettings', 'settingsversion') == 5:
|
if BMConfigParser().getint('bitmessagesettings', 'settingsversion') == 5:
|
||||||
|
@ -240,8 +239,8 @@ class sqlThread(threading.Thread):
|
||||||
# Raise the default required difficulty from 1 to 2
|
# Raise the default required difficulty from 1 to 2
|
||||||
# With the change to protocol v3, this is obsolete.
|
# With the change to protocol v3, this is obsolete.
|
||||||
if BMConfigParser().getint('bitmessagesettings', 'settingsversion') == 6:
|
if BMConfigParser().getint('bitmessagesettings', 'settingsversion') == 6:
|
||||||
"""if int(shared.config.get('bitmessagesettings','defaultnoncetrialsperbyte')) == protocol.networkDefaultProofOfWorkNonceTrialsPerByte:
|
"""if int(shared.config.get('bitmessagesettings','defaultnoncetrialsperbyte')) == defaults.networkDefaultProofOfWorkNonceTrialsPerByte:
|
||||||
shared.config.set('bitmessagesettings','defaultnoncetrialsperbyte', str(protocol.networkDefaultProofOfWorkNonceTrialsPerByte * 2))
|
shared.config.set('bitmessagesettings','defaultnoncetrialsperbyte', str(defaults.networkDefaultProofOfWorkNonceTrialsPerByte * 2))
|
||||||
"""
|
"""
|
||||||
BMConfigParser().set('bitmessagesettings', 'settingsversion', '7')
|
BMConfigParser().set('bitmessagesettings', 'settingsversion', '7')
|
||||||
|
|
||||||
|
@ -307,8 +306,8 @@ class sqlThread(threading.Thread):
|
||||||
|
|
||||||
# With the change to protocol version 3, reset the user-settable difficulties to 1
|
# With the change to protocol version 3, reset the user-settable difficulties to 1
|
||||||
if BMConfigParser().getint('bitmessagesettings', 'settingsversion') == 8:
|
if BMConfigParser().getint('bitmessagesettings', 'settingsversion') == 8:
|
||||||
BMConfigParser().set('bitmessagesettings','defaultnoncetrialsperbyte', str(protocol.networkDefaultProofOfWorkNonceTrialsPerByte))
|
BMConfigParser().set('bitmessagesettings','defaultnoncetrialsperbyte', str(defaults.networkDefaultProofOfWorkNonceTrialsPerByte))
|
||||||
BMConfigParser().set('bitmessagesettings','defaultpayloadlengthextrabytes', str(protocol.networkDefaultPayloadLengthExtraBytes))
|
BMConfigParser().set('bitmessagesettings','defaultpayloadlengthextrabytes', str(defaults.networkDefaultPayloadLengthExtraBytes))
|
||||||
previousTotalDifficulty = int(BMConfigParser().getint('bitmessagesettings', 'maxacceptablenoncetrialsperbyte')) / 320
|
previousTotalDifficulty = int(BMConfigParser().getint('bitmessagesettings', 'maxacceptablenoncetrialsperbyte')) / 320
|
||||||
previousSmallMessageDifficulty = int(BMConfigParser().getint('bitmessagesettings', 'maxacceptablepayloadlengthextrabytes')) / 14000
|
previousSmallMessageDifficulty = int(BMConfigParser().getint('bitmessagesettings', 'maxacceptablepayloadlengthextrabytes')) / 14000
|
||||||
BMConfigParser().set('bitmessagesettings','maxacceptablenoncetrialsperbyte', str(previousTotalDifficulty * 1000))
|
BMConfigParser().set('bitmessagesettings','maxacceptablenoncetrialsperbyte', str(previousTotalDifficulty * 1000))
|
||||||
|
@ -336,9 +335,9 @@ class sqlThread(threading.Thread):
|
||||||
|
|
||||||
# sanity check
|
# sanity check
|
||||||
if BMConfigParser().getint('bitmessagesettings', 'maxacceptablenoncetrialsperbyte') == 0:
|
if BMConfigParser().getint('bitmessagesettings', 'maxacceptablenoncetrialsperbyte') == 0:
|
||||||
BMConfigParser().set('bitmessagesettings','maxacceptablenoncetrialsperbyte', str(defaults.ridiculousDifficulty * protocol.networkDefaultProofOfWorkNonceTrialsPerByte))
|
BMConfigParser().set('bitmessagesettings','maxacceptablenoncetrialsperbyte', str(defaults.ridiculousDifficulty * defaults.networkDefaultProofOfWorkNonceTrialsPerByte))
|
||||||
if BMConfigParser().getint('bitmessagesettings', 'maxacceptablepayloadlengthextrabytes') == 0:
|
if BMConfigParser().getint('bitmessagesettings', 'maxacceptablepayloadlengthextrabytes') == 0:
|
||||||
BMConfigParser().set('bitmessagesettings','maxacceptablepayloadlengthextrabytes', str(defaults.ridiculousDifficulty * protocol.networkDefaultPayloadLengthExtraBytes))
|
BMConfigParser().set('bitmessagesettings','maxacceptablepayloadlengthextrabytes', str(defaults.ridiculousDifficulty * defaults.networkDefaultPayloadLengthExtraBytes))
|
||||||
|
|
||||||
# The format of data stored in the pubkeys table has changed. Let's
|
# The format of data stored in the pubkeys table has changed. Let's
|
||||||
# clear it, and the pubkeys from inventory, so that they'll be re-downloaded.
|
# clear it, and the pubkeys from inventory, so that they'll be re-downloaded.
|
||||||
|
|
|
@ -6,3 +6,8 @@ ridiculousDifficulty = 20000000
|
||||||
# it as default whenever the user changes the "method" selection for
|
# it as default whenever the user changes the "method" selection for
|
||||||
# namecoin integration to "namecoind".
|
# namecoin integration to "namecoind".
|
||||||
namecoinDefaultRpcPort = "8336"
|
namecoinDefaultRpcPort = "8336"
|
||||||
|
|
||||||
|
#If changed, these values will cause particularly unexpected behavior: You won't be able to either send or receive messages because the proof of work you do (or demand) won't match that done or demanded by others. Don't change them!
|
||||||
|
networkDefaultProofOfWorkNonceTrialsPerByte = 1000 #The amount of work that should be performed (and demanded) per byte of the payload.
|
||||||
|
networkDefaultPayloadLengthExtraBytes = 1000 #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.
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
import ConfigParser
|
import ConfigParser
|
||||||
from configparser import BMConfigParser
|
from configparser import BMConfigParser
|
||||||
|
import defaults
|
||||||
import sys
|
import sys
|
||||||
import os
|
import os
|
||||||
import locale
|
import locale
|
||||||
|
@ -10,7 +11,6 @@ from distutils.version import StrictVersion
|
||||||
|
|
||||||
from namecoin import ensureNamecoinOptions
|
from namecoin import ensureNamecoinOptions
|
||||||
import paths
|
import paths
|
||||||
import protocol
|
|
||||||
import state
|
import state
|
||||||
|
|
||||||
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.
|
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.
|
||||||
|
@ -92,9 +92,9 @@ def loadConfig():
|
||||||
BMConfigParser().set(
|
BMConfigParser().set(
|
||||||
'bitmessagesettings', 'messagesencrypted', 'false')
|
'bitmessagesettings', 'messagesencrypted', 'false')
|
||||||
BMConfigParser().set('bitmessagesettings', 'defaultnoncetrialsperbyte', str(
|
BMConfigParser().set('bitmessagesettings', 'defaultnoncetrialsperbyte', str(
|
||||||
protocol.networkDefaultProofOfWorkNonceTrialsPerByte))
|
defaults.networkDefaultProofOfWorkNonceTrialsPerByte))
|
||||||
BMConfigParser().set('bitmessagesettings', 'defaultpayloadlengthextrabytes', str(
|
BMConfigParser().set('bitmessagesettings', 'defaultpayloadlengthextrabytes', str(
|
||||||
protocol.networkDefaultPayloadLengthExtraBytes))
|
defaults.networkDefaultPayloadLengthExtraBytes))
|
||||||
BMConfigParser().set('bitmessagesettings', 'minimizeonclose', 'false')
|
BMConfigParser().set('bitmessagesettings', 'minimizeonclose', 'false')
|
||||||
BMConfigParser().set(
|
BMConfigParser().set(
|
||||||
'bitmessagesettings', 'maxacceptablenoncetrialsperbyte', '0')
|
'bitmessagesettings', 'maxacceptablenoncetrialsperbyte', '0')
|
||||||
|
|
|
@ -12,6 +12,7 @@ import traceback
|
||||||
from addresses import calculateInventoryHash, encodeVarint, decodeVarint, decodeAddress, varintDecodeError
|
from addresses import calculateInventoryHash, encodeVarint, decodeVarint, decodeAddress, varintDecodeError
|
||||||
from configparser import BMConfigParser
|
from configparser import BMConfigParser
|
||||||
from debug import logger
|
from debug import logger
|
||||||
|
import defaults
|
||||||
from helper_sql import sqlExecute
|
from helper_sql import sqlExecute
|
||||||
import highlevelcrypto
|
import highlevelcrypto
|
||||||
from inventory import Inventory
|
from inventory import Inventory
|
||||||
|
@ -29,10 +30,6 @@ BITFIELD_DOESACK = 1
|
||||||
eightBytesOfRandomDataUsedToDetectConnectionsToSelf = pack(
|
eightBytesOfRandomDataUsedToDetectConnectionsToSelf = pack(
|
||||||
'>Q', random.randrange(1, 18446744073709551615))
|
'>Q', random.randrange(1, 18446744073709551615))
|
||||||
|
|
||||||
#If changed, these values will cause particularly unexpected behavior: You won't be able to either send or receive messages because the proof of work you do (or demand) won't match that done or demanded by others. Don't change them!
|
|
||||||
networkDefaultProofOfWorkNonceTrialsPerByte = 1000 #The amount of work that should be performed (and demanded) per byte of the payload.
|
|
||||||
networkDefaultPayloadLengthExtraBytes = 1000 #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.
|
|
||||||
|
|
||||||
#Compiled struct for packing/unpacking headers
|
#Compiled struct for packing/unpacking headers
|
||||||
#New code should use CreatePacket instead of Header.pack
|
#New code should use CreatePacket instead of Header.pack
|
||||||
Header = Struct('!L12sL4s')
|
Header = Struct('!L12sL4s')
|
||||||
|
@ -97,10 +94,10 @@ def checkSocksIP(host):
|
||||||
def isProofOfWorkSufficient(data,
|
def isProofOfWorkSufficient(data,
|
||||||
nonceTrialsPerByte=0,
|
nonceTrialsPerByte=0,
|
||||||
payloadLengthExtraBytes=0):
|
payloadLengthExtraBytes=0):
|
||||||
if nonceTrialsPerByte < networkDefaultProofOfWorkNonceTrialsPerByte:
|
if nonceTrialsPerByte < defaults.networkDefaultProofOfWorkNonceTrialsPerByte:
|
||||||
nonceTrialsPerByte = networkDefaultProofOfWorkNonceTrialsPerByte
|
nonceTrialsPerByte = defaults.networkDefaultProofOfWorkNonceTrialsPerByte
|
||||||
if payloadLengthExtraBytes < networkDefaultPayloadLengthExtraBytes:
|
if payloadLengthExtraBytes < defaults.networkDefaultPayloadLengthExtraBytes:
|
||||||
payloadLengthExtraBytes = networkDefaultPayloadLengthExtraBytes
|
payloadLengthExtraBytes = defaults.networkDefaultPayloadLengthExtraBytes
|
||||||
endOfLifeTime, = unpack('>Q', data[8:16])
|
endOfLifeTime, = unpack('>Q', data[8:16])
|
||||||
TTL = endOfLifeTime - int(time.time())
|
TTL = endOfLifeTime - int(time.time())
|
||||||
if TTL < 300:
|
if TTL < 300:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user