コード例 #1
0
ファイル: addr.py プロジェクト: volekerb/neo-python
 def deserialize_from_bytes(cls, data_stream: Union[bytes, bytearray]):
     """ Deserialize object from a byte array. """
     br = BinaryReader(stream=data_stream)
     addr_payload = cls()
     addr_payload.deserialize(br)
     br.cleanup()
     return addr_payload
コード例 #2
0
ファイル: header.py プロジェクト: volekerb/neo-python
 def deserialize_from_bytes(cls, data_stream: Union[bytes, bytearray]) -> 'Header':
     """ Deserialize object from a byte array. """
     br = BinaryReader(stream=data_stream)
     header = cls(None, None, None, None, None, None, None)
     try:
         header.deserialize(br)
     except DeserializationError:
         return None
     br.cleanup()
     return header
コード例 #3
0
ファイル: inventory.py プロジェクト: volekerb/neo-python
 def deserialize_from_bytes(cls, data_stream: Union[bytes, bytearray]):
     """ Deserialize object from a byte array. """
     br = BinaryReader(stream=data_stream)
     inv_payload = cls()
     try:
         inv_payload.deserialize(br)
     except ValueError:
         return None
     finally:
         br.cleanup()
     return inv_payload
コード例 #4
0
ファイル: block.py プロジェクト: volekerb/neo-python
 def deserialize_from_bytes(cls, data_stream: Union[bytes, bytearray]) -> 'Block':
     """ Deserialize object from a byte array. """
     br = BinaryReader(stream=data_stream)
     block = cls(None, None, None, None, None, None)
     try:
         block.deserialize(br)
         # at this point we do not fully support all classes that can build up a block (e.g. Transactions)
         # the normal size calculation would request each class for its size and sum them up
         # we can shortcut this calculation in the absence of those classes by just determining the amount of bytes
         # in the payload
         block._size = len(data_stream)
     except ValueError:
         return None
     finally:
         br.cleanup()
     return block