Solved ackreceived issue

This commit is contained in:
jai.s 2020-03-02 18:43:56 +05:30
parent a5b38cacaf
commit cb1f1962e8
No known key found for this signature in database
GPG Key ID: 360CFA25EFC67D12
3 changed files with 9 additions and 8 deletions

View File

@ -141,7 +141,7 @@ class BMProto(AdvancedDispatcher, ObjectTracker):
except BMObjectAlreadyHaveError:
logger.debug(
'%(host)s:%(port)i already got object, skipping',
self.destinaestion._asdict())
self.destination._asdict())
except struct.error:
logger.debug('decoding error, skipping')
except ValueError:
@ -420,13 +420,11 @@ class BMProto(AdvancedDispatcher, ObjectTracker):
if self.object.inventoryHash in Inventory()._realInventory and Dandelion().hasHash(self.object.inventoryHash):
Dandelion().removeHash(self.object.inventoryHash, "cycle detection")
[self.object.inventoryHash] = (
Inventory()._realInventory[self.object.inventoryHash] = (
self.object.objectType, self.object.streamNumber,
memoryview(self.payload[objectOffset:]), self.object.expiresTime,
memoryview(self.object.tag)
)
Inventory()[self.object.inventoryHash]
self.handleReceivedObject(
self.object.streamNumber, self.object.inventoryHash)
invQueue.put((

View File

@ -289,7 +289,7 @@ def isProofOfWorkSufficient(
def CreatePacket(command, payload=''):
"""Construct and return a number of bytes from a payload"""
payload = payload if type(payload) in [bytes, bytearray] else payload.encode()
payload = payload if type(payload) in [bytes, bytearray,memoryview] else payload.encode()
payload_length = len(payload)
checksum = hashlib.sha512(payload).digest()[0:4]
byte = bytearray(Header.size + payload_length)

View File

@ -42,6 +42,9 @@ class SqliteInventory(InventoryStorage): # pylint: disable=too-many-ancestors
def __getitem__(self, hash_):
with self.lock:
if isinstance(hash_,memoryview) and bytes(hash_) in self._inventory :
return self._inventory[bytes(hash_)]
else:
if hash_ in self._inventory:
return self._inventory[hash_]
rows = sqlQuery(