apiAddressGeneratorReturnQueue is now in the shared module #254

Merged
Atheros1 merged 1 commits from master into master 2013-06-25 05:46:55 +02:00
Showing only changes of commit 5bb339c0fe - Show all commits

View File

@ -187,11 +187,11 @@ class MySimpleXMLRPCRequestHandler(SimpleXMLRPCRequestHandler):
unicode(label, 'utf-8') unicode(label, 'utf-8')
except: except:
return 'API Error 0017: Label is not valid UTF-8 data.' return 'API Error 0017: Label is not valid UTF-8 data.'
apiAddressGeneratorReturnQueue.queue.clear() shared.apiAddressGeneratorReturnQueue.queue.clear()
streamNumberForAddress = 1 streamNumberForAddress = 1
shared.addressGeneratorQueue.put(( shared.addressGeneratorQueue.put((
'createRandomAddress', 3, streamNumberForAddress, label, 1, "", eighteenByteRipe, nonceTrialsPerByte, payloadLengthExtraBytes)) 'createRandomAddress', 3, streamNumberForAddress, label, 1, "", eighteenByteRipe, nonceTrialsPerByte, payloadLengthExtraBytes))
return apiAddressGeneratorReturnQueue.get() return shared.apiAddressGeneratorReturnQueue.get()
elif method == 'createDeterministicAddresses': elif method == 'createDeterministicAddresses':
if len(params) == 0: if len(params) == 0:
return 'API Error 0000: I need parameters!' return 'API Error 0000: I need parameters!'
@ -264,13 +264,13 @@ class MySimpleXMLRPCRequestHandler(SimpleXMLRPCRequestHandler):
return 'API Error 0004: Why would you ask me to generate 0 addresses for you?' return 'API Error 0004: Why would you ask me to generate 0 addresses for you?'
if numberOfAddresses > 999: if numberOfAddresses > 999:
return 'API Error 0005: You have (accidentally?) specified too many addresses to make. Maximum 999. This check only exists to prevent mischief; if you really want to create more addresses than this, contact the Bitmessage developers and we can modify the check or you can do it yourself by searching the source code for this message.' return 'API Error 0005: You have (accidentally?) specified too many addresses to make. Maximum 999. This check only exists to prevent mischief; if you really want to create more addresses than this, contact the Bitmessage developers and we can modify the check or you can do it yourself by searching the source code for this message.'
apiAddressGeneratorReturnQueue.queue.clear() shared.apiAddressGeneratorReturnQueue.queue.clear()
print 'Requesting that the addressGenerator create', numberOfAddresses, 'addresses.' print 'Requesting that the addressGenerator create', numberOfAddresses, 'addresses.'
shared.addressGeneratorQueue.put( shared.addressGeneratorQueue.put(
('createDeterministicAddresses', addressVersionNumber, streamNumber, ('createDeterministicAddresses', addressVersionNumber, streamNumber,
'unused API address', numberOfAddresses, passphrase, eighteenByteRipe, nonceTrialsPerByte, payloadLengthExtraBytes)) 'unused API address', numberOfAddresses, passphrase, eighteenByteRipe, nonceTrialsPerByte, payloadLengthExtraBytes))
data = '{"addresses":[' data = '{"addresses":['
queueReturn = apiAddressGeneratorReturnQueue.get() queueReturn = shared.apiAddressGeneratorReturnQueue.get()
for item in queueReturn: for item in queueReturn:
if len(data) > 20: if len(data) > 20:
data += ',' data += ','
@ -290,12 +290,12 @@ class MySimpleXMLRPCRequestHandler(SimpleXMLRPCRequestHandler):
return 'API Error 0002: The address version number currently must be 3. ' + addressVersionNumber + ' isn\'t supported.' return 'API Error 0002: The address version number currently must be 3. ' + addressVersionNumber + ' isn\'t supported.'
if streamNumber != 1: if streamNumber != 1:
return 'API Error 0003: The stream number must be 1. Others aren\'t supported.' return 'API Error 0003: The stream number must be 1. Others aren\'t supported.'
apiAddressGeneratorReturnQueue.queue.clear() shared.apiAddressGeneratorReturnQueue.queue.clear()
print 'Requesting that the addressGenerator create', numberOfAddresses, 'addresses.' print 'Requesting that the addressGenerator create', numberOfAddresses, 'addresses.'
shared.addressGeneratorQueue.put( shared.addressGeneratorQueue.put(
('getDeterministicAddress', addressVersionNumber, ('getDeterministicAddress', addressVersionNumber,
streamNumber, 'unused API address', numberOfAddresses, passphrase, eighteenByteRipe)) streamNumber, 'unused API address', numberOfAddresses, passphrase, eighteenByteRipe))
return apiAddressGeneratorReturnQueue.get() return shared.apiAddressGeneratorReturnQueue.get()
elif method == 'getAllInboxMessages': elif method == 'getAllInboxMessages':
shared.sqlLock.acquire() shared.sqlLock.acquire()
shared.sqlSubmitQueue.put( shared.sqlSubmitQueue.put(