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:
|
||||||
|
@ -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,6 +42,9 @@ class SqliteInventory(InventoryStorage): # pylint: disable=too-many-ancestors
|
||||||
|
|
||||||
def __getitem__(self, hash_):
|
def __getitem__(self, hash_):
|
||||||
with self.lock:
|
with self.lock:
|
||||||
|
if isinstance(hash_,memoryview) and bytes(hash_) in self._inventory :
|
||||||
|
return self._inventory[bytes(hash_)]
|
||||||
|
else:
|
||||||
if hash_ in self._inventory:
|
if hash_ in self._inventory:
|
||||||
return self._inventory[hash_]
|
return self._inventory[hash_]
|
||||||
rows = sqlQuery(
|
rows = sqlQuery(
|
||||||
|
|
Reference in New Issue
Block a user