removed unused code and return ackdata from inset method insted of msgid

This commit is contained in:
navjot 2020-11-16 18:50:28 +05:30
parent beaece254c
commit 61f7f32dfc
No known key found for this signature in database
GPG Key ID: 9EE70AFD71357F1C
6 changed files with 16 additions and 22 deletions

View File

@ -1163,8 +1163,8 @@ class BMRPCDispatcher(object):
toAddress = str_broadcast_subscribers toAddress = str_broadcast_subscribers
helper_sent.insert( helper_sent.insert(
toAddress=toAddress, fromAddress=fromAddress, fromAddress=fromAddress, subject=subject,
subject=subject, message=message, status='broadcastqueued', message=message, status='broadcastqueued',
encoding=encodingType) encoding=encodingType)
toLabel = str_broadcast_subscribers toLabel = str_broadcast_subscribers

View File

@ -966,8 +966,6 @@ def sendMessage(sender="", recv="", broadcast=None, subject="", body="", reply=F
if not network.stats.connectedHostsList(): if not network.stats.connectedHostsList():
set_background_title(d, "Not connected warning") set_background_title(d, "Not connected warning")
scrollbox(d, unicode("Because you are not currently connected to the network, ")) scrollbox(d, unicode("Because you are not currently connected to the network, "))
stealthLevel = BMConfigParser().safeGetInt('bitmessagesettings', 'ackstealthlevel')
ackdata = genAckPayload(decodeAddress(addr)[2], stealthLevel)
helper_sent.insert( helper_sent.insert(
toAddress=addr, fromAddress=sender, subject=subject, message=body) toAddress=addr, fromAddress=sender, subject=subject, message=body)
queues.workerQueue.put(("sendmessage", addr)) queues.workerQueue.put(("sendmessage", addr))
@ -977,10 +975,8 @@ def sendMessage(sender="", recv="", broadcast=None, subject="", body="", reply=F
scrollbox(d, unicode("You must specify an address to send the message from.")) scrollbox(d, unicode("You must specify an address to send the message from."))
else: else:
# dummy ackdata, no need for stealth # dummy ackdata, no need for stealth
ackdata = genAckPayload(decodeAddress(addr)[2], 0)
recv = BROADCAST_STR
helper_sent.insert( helper_sent.insert(
toAddress=recv, fromAddress=sender, subject=subject, fromAddress=sender, subject=subject,
message=body, status='broadcastqueued') message=body, status='broadcastqueued')
queues.workerQueue.put(('sendbroadcast', '')) queues.workerQueue.put(('sendbroadcast', ''))

View File

@ -2208,7 +2208,7 @@ class MyForm(settingsmixin.SMainWindow):
# msgid. We don't know what this will be until the POW is done. # msgid. We don't know what this will be until the POW is done.
helper_sent.insert( helper_sent.insert(
toAddress=toAddress, fromAddress=fromAddress, fromAddress=fromAddress,
subject=subject, message=message, subject=subject, message=message,
status='broadcastqueued', encoding=encoding) status='broadcastqueued', encoding=encoding)

View File

@ -745,13 +745,9 @@ class objectProcessor(threading.Thread):
# We don't actually need the ackdata for acknowledgement # We don't actually need the ackdata for acknowledgement
# since this is a broadcast message but we can use it to # since this is a broadcast message but we can use it to
# update the user interface when the POW is done generating. # update the user interface when the POW is done generating.
streamNumber = decodeAddress(fromAddress)[2]
ackdata = genAckPayload(streamNumber, 0)
toAddress = '[Broadcast subscribers]' toAddress = '[Broadcast subscribers]'
helper_sent.insert( helper_sent.insert(
toAddress=toAddress,
fromAddress=fromAddress, fromAddress=fromAddress,
status='broadcastqueued', status='broadcastqueued',
subject=subject, subject=subject,

View File

@ -11,9 +11,9 @@ from helper_sql import sqlExecute
# pylint: disable=too-many-arguments # pylint: disable=too-many-arguments
def insert(msgid=None, toAddress=None, fromAddress=None, subject=None, message=None, def insert(msgid=None, toAddress='[Broadcast subscribers]', fromAddress=None, subject=None,
status=None, ripe=None, ackdata=None, sentTime=None, lastActionTime=None, message=None, status='msgqueued', ripe=None, ackdata=None, sentTime=None,
sleeptill=0, retryNumber=0, encoding=2, ttl=None, folder='sent'): lastActionTime=None, sleeptill=0, retryNumber=0, encoding=2, ttl=None, folder='sent'):
"""Perform an insert into the `sent` table""" """Perform an insert into the `sent` table"""
# pylint: disable=unused-variable # pylint: disable=unused-variable
# pylint: disable-msg=too-many-locals # pylint: disable-msg=too-many-locals
@ -21,7 +21,8 @@ def insert(msgid=None, toAddress=None, fromAddress=None, subject=None, message=N
msgid = msgid if msgid else uuid.uuid4().bytes msgid = msgid if msgid else uuid.uuid4().bytes
if not ripe or not ackdata: if not ripe or not ackdata:
new_status, addressVersionNumber, streamNumber, new_ripe = decodeAddress(toAddress) addr = fromAddress if toAddress == '[Broadcast subscribers]' else toAddress
new_status, addressVersionNumber, streamNumber, new_ripe = decodeAddress(addr)
if not ripe: if not ripe:
ripe = new_ripe ripe = new_ripe
@ -34,7 +35,6 @@ def insert(msgid=None, toAddress=None, fromAddress=None, subject=None, message=N
sentTime = sentTime if sentTime else int(time.time()) # sentTime (this doesn't change) sentTime = sentTime if sentTime else int(time.time()) # sentTime (this doesn't change)
lastActionTime = lastActionTime if lastActionTime else int(time.time()) lastActionTime = lastActionTime if lastActionTime else int(time.time())
status = status if status else 'msgqueued'
ttl = ttl if ttl else BMConfigParser().getint('bitmessagesettings', 'ttl') ttl = ttl if ttl else BMConfigParser().getint('bitmessagesettings', 'ttl')
t = (msgid, toAddress, ripe, fromAddress, subject, message, ackdata, t = (msgid, toAddress, ripe, fromAddress, subject, message, ackdata,
@ -42,4 +42,4 @@ def insert(msgid=None, toAddress=None, fromAddress=None, subject=None, message=N
encoding, ttl) encoding, ttl)
sqlExecute('''INSERT INTO sent VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)''', *t) sqlExecute('''INSERT INTO sent VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)''', *t)
return msgid return ackdata

View File

@ -19,6 +19,7 @@ import helper_sent
from bmconfigparser import BMConfigParser from bmconfigparser import BMConfigParser
from helper_msgcoding import MsgEncode, MsgDecode from helper_msgcoding import MsgEncode, MsgDecode
from helper_startup import start_proxyconfig from helper_startup import start_proxyconfig
from helper_sql import sqlQuery
from network import asyncore_pollchoose as asyncore, knownnodes from network import asyncore_pollchoose as asyncore, knownnodes
from network.bmproto import BMProto from network.bmproto import BMProto
from network.connectionpool import BMConnectionPool from network.connectionpool import BMConnectionPool
@ -246,12 +247,13 @@ class TestCore(unittest.TestCase):
toAddress = 'BM-2cVWtdUzPwF7UNGDrZftWuHWgjdfkj89fdf' toAddress = 'BM-2cVWtdUzPwF7UNGDrZftWuHWgjdfkj89fdf'
message = 'test message' message = 'test message'
subject = 'test subject' subject = 'test subject'
status = 'msgqueued'
result = helper_sent.insert( result = helper_sent.insert(
toAddress=toAddress, fromAddress=fromAddress, subject=subject, toAddress=toAddress, fromAddress=fromAddress,
message=message, status=status, subject=subject, message=message,
) )
self.assertNotEqual(result, '') queryreturn = sqlQuery(
'''select msgid from sent where ackdata=?''', result)
self.assertNotEqual(queryreturn[0][0], '')
def run(): def run():