commit
0b7070eae4
|
@ -141,7 +141,7 @@ class BMProto(AdvancedDispatcher, ObjectTracker):
|
||||||
except BMObjectAlreadyHaveError:
|
except BMObjectAlreadyHaveError:
|
||||||
logger.debug(
|
logger.debug(
|
||||||
'%(host)s:%(port)i already got object, skipping',
|
'%(host)s:%(port)i already got object, skipping',
|
||||||
self.destinaestion._asdict())
|
self.destination._asdict())
|
||||||
except struct.error:
|
except struct.error:
|
||||||
logger.debug('decoding error, skipping')
|
logger.debug('decoding error, skipping')
|
||||||
except ValueError:
|
except ValueError:
|
||||||
|
@ -409,7 +409,7 @@ class BMProto(AdvancedDispatcher, ObjectTracker):
|
||||||
try:
|
try:
|
||||||
self.object.checkObjectByType()
|
self.object.checkObjectByType()
|
||||||
objectProcessorQueue.put((
|
objectProcessorQueue.put((
|
||||||
self.object.objectType, memoryview(self.object.data)))
|
self.object.objectType, memoryview(self.object.data)))
|
||||||
except BMObjectInvalidError:
|
except BMObjectInvalidError:
|
||||||
BMProto.stopDownloadingObject(self.object.inventoryHash, True)
|
BMProto.stopDownloadingObject(self.object.inventoryHash, True)
|
||||||
else:
|
else:
|
||||||
|
@ -420,13 +420,11 @@ class BMProto(AdvancedDispatcher, ObjectTracker):
|
||||||
|
|
||||||
if self.object.inventoryHash in Inventory()._realInventory and Dandelion().hasHash(self.object.inventoryHash):
|
if self.object.inventoryHash in Inventory()._realInventory and Dandelion().hasHash(self.object.inventoryHash):
|
||||||
Dandelion().removeHash(self.object.inventoryHash, "cycle detection")
|
Dandelion().removeHash(self.object.inventoryHash, "cycle detection")
|
||||||
[self.object.inventoryHash] = (
|
Inventory()._realInventory[self.object.inventoryHash] = (
|
||||||
|
|
||||||
self.object.objectType, self.object.streamNumber,
|
self.object.objectType, self.object.streamNumber,
|
||||||
memoryview(self.payload[objectOffset:]), self.object.expiresTime,
|
memoryview(self.payload[objectOffset:]), self.object.expiresTime,
|
||||||
memoryview(self.object.tag)
|
memoryview(self.object.tag)
|
||||||
)
|
)
|
||||||
Inventory()[self.object.inventoryHash]
|
|
||||||
self.handleReceivedObject(
|
self.handleReceivedObject(
|
||||||
self.object.streamNumber, self.object.inventoryHash)
|
self.object.streamNumber, self.object.inventoryHash)
|
||||||
invQueue.put((
|
invQueue.put((
|
||||||
|
|
|
@ -289,7 +289,7 @@ def isProofOfWorkSufficient(
|
||||||
|
|
||||||
def CreatePacket(command, payload=''):
|
def CreatePacket(command, payload=''):
|
||||||
"""Construct and return a number of bytes from a 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)
|
payload_length = len(payload)
|
||||||
checksum = hashlib.sha512(payload).digest()[0:4]
|
checksum = hashlib.sha512(payload).digest()[0:4]
|
||||||
byte = bytearray(Header.size + payload_length)
|
byte = bytearray(Header.size + payload_length)
|
||||||
|
|
|
@ -42,8 +42,11 @@ class SqliteInventory(InventoryStorage): # pylint: disable=too-many-ancestors
|
||||||
|
|
||||||
def __getitem__(self, hash_):
|
def __getitem__(self, hash_):
|
||||||
with self.lock:
|
with self.lock:
|
||||||
if hash_ in self._inventory:
|
if isinstance(hash_,memoryview) and bytes(hash_) in self._inventory :
|
||||||
return self._inventory[hash_]
|
return self._inventory[bytes(hash_)]
|
||||||
|
else:
|
||||||
|
if hash_ in self._inventory:
|
||||||
|
return self._inventory[hash_]
|
||||||
rows = sqlQuery(
|
rows = sqlQuery(
|
||||||
'SELECT objecttype, streamnumber, payload, expirestime, tag'
|
'SELECT objecttype, streamnumber, payload, expirestime, tag'
|
||||||
' FROM inventory WHERE hash=?', sqlite3.Binary(hash_))
|
' FROM inventory WHERE hash=?', sqlite3.Binary(hash_))
|
||||||
|
|
Reference in New Issue
Block a user