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
helper_sent.insert(
toAddress=toAddress, fromAddress=fromAddress,
subject=subject, message=message, status='broadcastqueued',
fromAddress=fromAddress, subject=subject,
message=message, status='broadcastqueued',
encoding=encodingType)
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():
set_background_title(d, "Not connected warning")
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(
toAddress=addr, fromAddress=sender, subject=subject, message=body)
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."))
else:
# dummy ackdata, no need for stealth
ackdata = genAckPayload(decodeAddress(addr)[2], 0)
recv = BROADCAST_STR
helper_sent.insert(
toAddress=recv, fromAddress=sender, subject=subject,
fromAddress=sender, subject=subject,
message=body, status='broadcastqueued')
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.
helper_sent.insert(
toAddress=toAddress, fromAddress=fromAddress,
fromAddress=fromAddress,
subject=subject, message=message,
status='broadcastqueued', encoding=encoding)

View File

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

View File

@ -11,9 +11,9 @@ from helper_sql import sqlExecute
# pylint: disable=too-many-arguments
def insert(msgid=None, toAddress=None, fromAddress=None, subject=None, message=None,
status=None, ripe=None, ackdata=None, sentTime=None, lastActionTime=None,
sleeptill=0, retryNumber=0, encoding=2, ttl=None, folder='sent'):
def insert(msgid=None, toAddress='[Broadcast subscribers]', fromAddress=None, subject=None,
message=None, status='msgqueued', ripe=None, ackdata=None, sentTime=None,
lastActionTime=None, sleeptill=0, retryNumber=0, encoding=2, ttl=None, folder='sent'):
"""Perform an insert into the `sent` table"""
# pylint: disable=unused-variable
# 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
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:
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)
lastActionTime = lastActionTime if lastActionTime else int(time.time())
status = status if status else 'msgqueued'
ttl = ttl if ttl else BMConfigParser().getint('bitmessagesettings', 'ttl')
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)
sqlExecute('''INSERT INTO sent VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)''', *t)
return msgid
return ackdata

View File

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