示例#1
0
    def deserialize(self, reader: serialization.BinaryReader) -> None:
        self.magic = reader.read_uint32()
        compiler_with_version = reader.read_bytes(64).decode('utf-8')
        self.compiler, version = compiler_with_version.rsplit('-', maxsplit=1)
        self.version = Version.deserialize_from_bytes(
            version[:32].encode('utf-8'))

        assert reader.read_uint16() == 0  # 2 reserved bytes
        reader.read_var_int(128)  # TODO: method tokens
        assert reader.read_uint16() == 0  # 2 reserved bytes

        self.script = reader.read_var_bytes()
        self.checksum = reader.read_bytes(4)
        if self.checksum != self.compute_checksum():
            raise ValueError("Deserialization error - invalid checksum")
示例#2
0
    def deserialize_without_type(self,
                                 reader: serialization.BinaryReader) -> None:
        """
        Deserialize the object from a binary stream without deserializing the base class `type` property.

        Args:
            reader: instance.
        """
        self.port = reader.read_uint16()
示例#3
0
    def deserialize_unsigned(self, reader: serialization.BinaryReader) -> None:
        """
        Deserialize the object from a binary stream excluding the validation byte + witness.

        Args:
            reader: instance.
        """
        self.version = reader.read_uint32()
        self.prev_hash = reader.read_serializable(types.UInt256)
        self.block_index = reader.read_uint32()
        self.validator_index = reader.read_uint16()
        self.data = reader.read_var_bytes()
示例#4
0
文件: block.py 项目: EdgeDLT/neo3-boa
    def deserialize(self, reader: serialization.BinaryReader) -> None:
        """
        Deserialize the object from a binary stream.

        Args:
            reader: instance.

        Raises:
            ValueError: if `count` is zero or exceeds
               :const:`~neo3.network.payloads.getblocks.GetBlockDataPayload.MAX_BLOCKS_COUNT`.
        """
        self.index_start = reader.read_uint32()
        self.count = reader.read_uint16()
        if self.count == 0 or self.count > self.MAX_BLOCKS_COUNT:
            raise ValueError("Deserialization error - invalid count")