Beispiel #1
0
 def load(cls, data):
     """
     Create a new transfer from a dict in json format.
     :param dict data: The loaded data
     :return: A new transfer
     :rtype: Transfer
     """
     return cls(
         data["hash"],
         TransferState[data["state"]],
         BlockId.from_str(data["blockid"]) if data["blockid"] else None,
         data["metadata"],
         data["local"],
     )
Beispiel #2
0
    def blockid(self):
        """
        Get the block id.

        :return: The current block ID as [NUMBER-HASH] format.
        """
        try:
            block_number = self.network.current_blockid.number
            block = yield from self.bma_access.future_request(bma.blockchain.Block, req_args={"number": block_number})
            signed_raw = "{0}{1}\n".format(block["raw"], block["signature"])
        except ValueError as e:
            if "404" in str(e):
                return BlockId.empty()

        return Block.from_signed_raw(signed_raw).blockid
Beispiel #3
0
    async def blockid(self):
        """
        Get the block id.

        :return: The current block ID as [NUMBER-HASH] format.
        """
        try:
            block_number = self.network.current_blockid.number
            block = await self.bma_access.future_request(bma.blockchain.Block,
                                 req_args={'number': block_number})
            signed_raw = "{0}{1}\n".format(block['raw'], block['signature'])
        except ValueError as e:
            if '404' in str(e):
                return BlockId.empty()

        return Block.from_signed_raw(signed_raw).blockid