Пример #1
0
 def get_block_by_hash(self, block_hash):
     """
     Returns the requested block as specified by block hash.
     """
     validate_word(block_hash, title="Block Hash")
     block_header = self.get_block_header_by_hash(block_hash)
     return self.get_block_by_header(block_header)
Пример #2
0
 def get_block_by_hash(self, block_hash):
     """
     Returns the requested block as specified by block hash.
     """
     validate_word(block_hash, title="Block Hash")
     block_header = self.get_block_header_by_hash(block_hash)
     return self.get_block_by_header(block_header)
Пример #3
0
 def get_block_by_hash(self, block_hash):
     """
     Returns the requested block as specified by block hash.
     """
     validate_word(block_hash)
     block_header = self.get_block_header_by_hash(block_hash)
     vm = self.get_vm(block_header)
     return vm.get_block_by_header(block_header)
Пример #4
0
    def get_block_header_by_hash(self, block_hash):
        """
        Returns the requested block header as specified by block hash.

        Raises BlockNotFound if there's no block header with the given hash in the db.
        """
        validate_word(block_hash, title="Block Hash")
        return self.chaindb.get_block_header_by_hash(block_hash)
Пример #5
0
    def get_block_header_by_hash(self, block_hash):
        """
        Returns the requested block header as specified by block hash.

        Raises BlockNotFound if there's no block header with the given hash in the db.
        """
        validate_word(block_hash, title="Block Hash")
        return self.chaindb.get_block_header_by_hash(block_hash)
Пример #6
0
    def get_block_header_by_hash(self, block_hash):
        """
        Returns the requested block header as specified by block hash.

        Raises BlockNotFound if it is not present in the db.
        """
        validate_word(block_hash, title="Block Hash")
        try:
            block = self.db.get(block_hash)
        except KeyError:
            raise BlockNotFound("No block with hash {0} found".format(
                encode_hex(block_hash)))
        return rlp.decode(block, sedes=BlockHeader)
Пример #7
0
 def get_block_uncles(self, uncles_hash: Hash32) -> List[BlockHeader]:
     """
     Returns an iterable of uncle headers specified by the given uncles_hash
     """
     validate_word(uncles_hash, title="Uncles Hash")
     try:
         encoded_uncles = self.db[uncles_hash]
     except KeyError:
         raise HeaderNotFound(
             "No uncles found for hash {0}".format(uncles_hash))
     else:
         return rlp.decode(encoded_uncles,
                           sedes=rlp.sedes.CountableList(BlockHeader))
Пример #8
0
    def get_block_header_by_hash(self, block_hash: Hash32) -> BlockHeader:
        """
        Returns the requested block header as specified by block hash.

        Raises HeaderNotFound if it is not present in the db.
        """
        validate_word(block_hash, title="Block Hash")
        try:
            header_rlp = self.db[block_hash]
        except KeyError:
            raise HeaderNotFound("No header with hash {0} found".format(
                encode_hex(block_hash)))
        return _decode_block_header(header_rlp)
Пример #9
0
    def get_block_header_by_hash(self, block_hash):
        """
        Returns the requested block header as specified by block hash.

        Raises BlockNotFound if it is not present in the db.
        """
        validate_word(block_hash, title="Block Hash")
        try:
            block = self.db.get(block_hash)
        except KeyError:
            raise BlockNotFound("No block with hash {0} found".format(
                encode_hex(block_hash)))
        return rlp.decode(block, sedes=BlockHeader)
Пример #10
0
    def validate(self):
        validate_uint256(self.chain_id, title="Transaction.chain_id")
        validate_uint256(self.shard_id, title="Transaction.shard_id")

        validate_canonical_address(self.to, title="Transaction.to")
        validate_is_bytes(self.data, title="Transaction.data")

        validate_uint256(self.gas, title="Transaction.gas")

        validate_transaction_access_list(self.access_list,
                                         title="Transaction.access_list")

        validate_is_bytes(self.code, title="Transaction.code")
        validate_word(self.salt, title="Transaction.salt")

        super(ShardingTransaction, self).validate()
Пример #11
0
 def get_block_uncles(self, uncles_hash):
     validate_word(uncles_hash, title="Uncles Hash")
     return rlp.decode(self.db.get(uncles_hash), sedes=rlp.sedes.CountableList(BlockHeader))
Пример #12
0
 def get_block_uncles(self, uncles_hash):
     validate_word(uncles_hash, title="Uncles Hash")
     return rlp.decode(self.db.get(uncles_hash), sedes=rlp.sedes.CountableList(BlockHeader))
Пример #13
0
 def header_exists(self, block_hash: Hash32) -> bool:
     validate_word(block_hash, title="Block Hash")
     return block_hash in self.db
Пример #14
0
def test_validate_word(value, is_valid):
    if is_valid:
            validate_word(value)
    else:
        with pytest.raises(ValidationError):
            validate_word(value)
Пример #15
0
def test_validate_word(value, is_valid):
    if is_valid:
        validate_word(value)
    else:
        with pytest.raises(ValidationError):
            validate_word(value)