commit
0b7070eae4
|
@ -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:
|
||||
|
@ -409,7 +409,7 @@ class BMProto(AdvancedDispatcher, ObjectTracker):
|
|||
try:
|
||||
self.object.checkObjectByType()
|
||||
objectProcessorQueue.put((
|
||||
self.object.objectType, memoryview(self.object.data)))
|
||||
self.object.objectType, memoryview(self.object.data)))
|
||||
except BMObjectInvalidError:
|
||||
BMProto.stopDownloadingObject(self.object.inventoryHash, True)
|
||||
else:
|
||||
|
@ -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((
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -42,8 +42,11 @@ class SqliteInventory(InventoryStorage): # pylint: disable=too-many-ancestors
|
|||
|
||||
def __getitem__(self, hash_):
|
||||
with self.lock:
|
||||
if hash_ in self._inventory:
|
||||
return self._inventory[hash_]
|
||||
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(
|
||||
'SELECT objecttype, streamnumber, payload, expirestime, tag'
|
||||
' FROM inventory WHERE hash=?', sqlite3.Binary(hash_))
|
||||
|
|
Reference in New Issue
Block a user