コード例 #1
0
    def ToArray(self):
        """
        Get the byte data of self.

        Returns:
            bytes:
        """
        return Helper.ToArray(self)
コード例 #2
0
    def SendSerializedMessage(self, message):
        """
        Send the `message` to the remote client.

        Args:
            message (neo.Network.Message):
        """
        ba = Helper.ToArray(message)
        ba2 = binascii.unhexlify(ba)
        self.bytes_out += len(ba2)
        self.transport.write(ba2)
コード例 #3
0
ファイル: JsonRpcApi.py プロジェクト: rameshgr008/neo-python
    def get_blockheader_output(self, blockheader, params):

        if len(params) >= 2 and params[1]:
            jsn = blockheader.ToJson()
            jsn['confirmations'] = Blockchain.Default().Height - blockheader.Index + 1
            hash = Blockchain.Default().GetNextBlockHash(blockheader.Hash)
            if hash:
                jsn['nextblockhash'] = '0x%s' % hash.decode('utf-8')
            return jsn

        return Helper.ToArray(blockheader).decode('utf-8')
コード例 #4
0
    def get_tx_output(self, tx, height, params):

        if len(params) >= 2 and params[1]:
            jsn = tx.ToJson()
            if height >= 0:
                header = Blockchain.Default().GetHeaderByHeight(height)
                jsn['blockhash'] = header.Hash.To0xString()
                jsn['confirmations'] = Blockchain.Default().Height - header.Index + 1
                jsn['blocktime'] = header.Timestamp
            return jsn

        return Helper.ToArray(tx).decode('utf-8')
コード例 #5
0
    def __init__(self, command=None, payload=None):

        self.Command = command
        self.Magic = Settings.MAGIC

        if payload is None:
            payload = bytearray()
        else:
            payload = binascii.unhexlify(Helper.ToArray(payload))

        self.Checksum = Message.GetChecksum(payload)
        self.Payload = payload
コード例 #6
0
ファイル: NeoNode.py プロジェクト: yodash/neo-python
    def SendSerializedMessage(self, message):
        """
        Send the `message` to the remote client.

        Args:
            message (neo.Network.Message):
        """
        try:
            ba = Helper.ToArray(message)
            ba2 = binascii.unhexlify(ba)
            self.bytes_out += len(ba2)
            self.transport.write(ba2)
        except Exception as e:
            self.Log("Could not send serialized message %s " % e)
コード例 #7
0
ファイル: test_payloads.py プロジェクト: tanitall/neo-python
    def test_version_serialization(self):

        serialized = binascii.unhexlify( Helper.ToArray(self.payload))

        deserialized_version = IOHelper.AsSerializableWithType(serialized, 'neo.Network.Payloads.VersionPayload.VersionPayload')

        v = deserialized_version
        self.assertEqual(v.Nonce, self.nonce)
        self.assertEqual(v.Port, self.port)
        self.assertEqual(v.UserAgent, self.ua)
        self.assertEqual(v.Timestamp, self.payload.Timestamp)
        self.assertEqual(v.StartHeight, self.payload.StartHeight)
        self.assertEqual(v.Version, self.payload.Version)
        self.assertEqual(v.Services, self.payload.Services)
        self.assertEqual(v.Relay, self.payload.Relay)
コード例 #8
0
    def __init__(self, command=None, payload=None, print_payload=False):
        """
        Create an instance.

        Args:
            command (str): payload command i.e. "inv", "getdata". See NeoNode.MessageReceived() for more commands.
            payload (bytes): raw bytes of the payload.
            print_payload: UNUSED
        """
        self.Command = command
        self.Magic = settings.MAGIC

        if payload is None:
            payload = bytearray()
        else:
            payload = binascii.unhexlify(Helper.ToArray(payload))

        self.Checksum = Message.GetChecksum(payload)
        self.Payload = payload
コード例 #9
0
ファイル: Contract.py プロジェクト: pbanimus/neo-python
 def ToArray(self):
     return Helper.ToArray(self)
コード例 #10
0
 def SendSerializedMessage(self, message):
     ba = Helper.ToArray(message)
     ba2 = binascii.unhexlify(ba)
     self.bytes_out += len(ba2)
     self.transport.write(ba2)