API-related changes

This commit is contained in:
Jonathan Warren 2013-05-02 15:39:51 -04:00
parent c5d4f50dbd
commit de59b4adf1
3 changed files with 7 additions and 25 deletions

View File

@ -30,7 +30,7 @@ print 'Uncomment the next two lines to create a new random address.'
print 'Uncomment these next four lines to create new deterministic addresses.' print 'Uncomment these next four lines to create new deterministic addresses.'
#passphrase = 'asdfasdfqwer'.encode('base64') #passphrase = 'asdfasdfqwer'.encode('base64')
#jsonDeterministicAddresses = api.createDeterministicAddresses(passphrase, 2, 2, 1, False) #jsonDeterministicAddresses = api.createDeterministicAddresses(passphrase, 2, 3, 1, False)
#print jsonDeterministicAddresses #print jsonDeterministicAddresses
#print json.loads(jsonDeterministicAddresses) #print json.loads(jsonDeterministicAddresses)

View File

@ -3610,8 +3610,8 @@ class MySimpleXMLRPCRequestHandler(SimpleXMLRPCRequestHandler):
return 'API Error 0009: Invalid characters in address: '+ fromAddress return 'API Error 0009: Invalid characters in address: '+ fromAddress
if status == 'versiontoohigh': if status == 'versiontoohigh':
return 'API Error 0010: Address version number too high (or zero) in address: ' + fromAddress return 'API Error 0010: Address version number too high (or zero) in address: ' + fromAddress
if addressVersionNumber != 2: if addressVersionNumber < 2 or addressVersionNumber > 3:
return 'API Error 0011: the address version number currently must be 2. Others aren\'t supported. Check the fromAddress.' return 'API Error 0011: the address version number currently must be 2 or 3. Others aren\'t supported. Check the fromAddress.'
if streamNumber != 1: if streamNumber != 1:
return 'API Error 0012: the stream number must be 1. Others aren\'t supported. Check the fromAddress.' return 'API Error 0012: the stream number must be 1. Others aren\'t supported. Check the fromAddress.'
fromAddress = addBMIfNotPresent(fromAddress) fromAddress = addBMIfNotPresent(fromAddress)
@ -3653,14 +3653,6 @@ class singleAPI(threading.Thread):
se.serve_forever() se.serve_forever()
#The MySimpleXMLRPCRequestHandler class cannot emit signals (or at least I don't know how) because it is not a QT thread. It therefore puts data in a queue which this thread monitors and emits the signals on its behalf. #The MySimpleXMLRPCRequestHandler class cannot emit signals (or at least I don't know how) because it is not a QT thread. It therefore puts data in a queue which this thread monitors and emits the signals on its behalf.
"""class singleAPISignalHandler(QThread): """class singleAPISignalHandler(QThread):
def __init__(self, parent = None): def __init__(self, parent = None):
@ -3691,18 +3683,12 @@ class singleAPI(threading.Thread):
self.emit(SIGNAL("displayNewSentMessage(PyQt_PyObject,PyQt_PyObject,PyQt_PyObject,PyQt_PyObject,PyQt_PyObject,PyQt_PyObject)"),toAddress,toLabel,fromAddress,subject,message,ackdata)""" self.emit(SIGNAL("displayNewSentMessage(PyQt_PyObject,PyQt_PyObject,PyQt_PyObject,PyQt_PyObject,PyQt_PyObject,PyQt_PyObject)"),toAddress,toLabel,fromAddress,subject,message,ackdata)"""
selfInitiatedConnections = {} #This is a list of current connections (the thread pointers at least) selfInitiatedConnections = {} #This is a list of current connections (the thread pointers at least)
alreadyAttemptedConnectionsList = {} #This is a list of nodes to which we have already attempted a connection alreadyAttemptedConnectionsList = {} #This is a list of nodes to which we have already attempted a connection
ackdataForWhichImWatching = {} ackdataForWhichImWatching = {}
connectionsCount = {} #Used for the 'network status' tab. connectionsCount = {} #Used for the 'network status' tab.
connectionsCountLock = threading.Lock() connectionsCountLock = threading.Lock()
alreadyAttemptedConnectionsListLock = threading.Lock() alreadyAttemptedConnectionsListLock = threading.Lock()
eightBytesOfRandomDataUsedToDetectConnectionsToSelf = pack('>Q',random.randrange(1, 18446744073709551615)) eightBytesOfRandomDataUsedToDetectConnectionsToSelf = pack('>Q',random.randrange(1, 18446744073709551615))
connectedHostsList = {} #List of hosts to which we are connected. Used to guarantee that the outgoingSynSender threads won't connect to the same remote node twice. connectedHostsList = {} #List of hosts to which we are connected. Used to guarantee that the outgoingSynSender threads won't connect to the same remote node twice.
neededPubkeys = {} neededPubkeys = {}
@ -3711,7 +3697,6 @@ successfullyDecryptMessageTimings = [] #A list of the amounts of time it took to
apiAddressGeneratorReturnQueue = Queue.Queue() #The address generator thread uses this queue to get information back to the API thread. apiAddressGeneratorReturnQueue = Queue.Queue() #The address generator thread uses this queue to get information back to the API thread.
alreadyAttemptedConnectionsListResetTime = int(time.time()) #used to clear out the alreadyAttemptedConnectionsList periodically so that we will retry connecting to hosts to which we have already tried to connect. alreadyAttemptedConnectionsListResetTime = int(time.time()) #used to clear out the alreadyAttemptedConnectionsList periodically so that we will retry connecting to hosts to which we have already tried to connect.
#These constants are not at the top because if changed they 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! #These constants are not at the top because if changed they 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 = 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.
@ -3919,7 +3904,6 @@ if __name__ == "__main__":
import bitmessageqt import bitmessageqt
bitmessageqt.run() bitmessageqt.run()
if shared.config.getboolean('bitmessagesettings', 'startintray'): if shared.config.getboolean('bitmessagesettings', 'startintray'):
myapp.hide() myapp.hide()
myapp.trayIcon.show() myapp.trayIcon.show()
@ -3928,8 +3912,6 @@ if __name__ == "__main__":
#self.hide() #self.hide()
if 'win32' in sys.platform or 'win64' in sys.platform: if 'win32' in sys.platform or 'win64' in sys.platform:
myapp.setWindowFlags(Qt.ToolTip) myapp.setWindowFlags(Qt.ToolTip)
else: else:
print 'Running as a daemon. You can use Ctrl+C to exit.' print 'Running as a daemon. You can use Ctrl+C to exit.'
while True: while True:

View File

@ -10,11 +10,11 @@ def createDefaultKnownNodes(appdata):
############## Stream 1 ################ ############## Stream 1 ################
stream1 = {} stream1 = {}
stream1['84.48.88.42'] = (8444,int(time.time())) stream1['98.28.255.178'] = (8444,int(time.time()))
stream1['66.65.120.151'] = (8080,int(time.time())) stream1['66.65.120.151'] = (8080,int(time.time()))
stream1['76.180.233.38'] = (8444,int(time.time())) stream1['87.236.30.170'] = (8444,int(time.time()))
stream1['74.132.73.137'] = (8444,int(time.time())) stream1['163.118.75.118'] = (8444,int(time.time()))
stream1['60.242.109.18'] = (8444,int(time.time())) stream1['88.130.32.123'] = (8444,int(time.time()))
############# Stream 2 ################# ############# Stream 2 #################
stream2 = {} stream2 = {}