Пример #1
0
    def get_transaction_index(self, transaction_hash):
        try:
            encoded_key = self.db.get(make_transaction_hash_to_block_lookup_key(transaction_hash))
        except KeyError:
            raise TransactionNotFound(
                "Transaction {} not found in canonical chain".format(encode_hex(transaction_hash)))

        transaction_key = rlp.decode(encoded_key, sedes=TransactionKey)
        return (transaction_key.block_number, transaction_key.index)
Пример #2
0
    def get_transaction_index(self, transaction_hash):
        try:
            encoded_key = self.db.get(make_transaction_hash_to_block_lookup_key(transaction_hash))
        except KeyError:
            raise TransactionNotFound(
                "Transaction {} not found in canonical chain".format(encode_hex(transaction_hash)))

        transaction_key = rlp.decode(encoded_key, sedes=TransactionKey)
        return (transaction_key.block_number, transaction_key.index)
Пример #3
0
 def _add_transaction_to_canonical_chain(self, transaction_hash: bytes,
                                         block_header: BlockHeader,
                                         index: int) -> None:
     """
     :param bytes transaction_hash: the hash of the transaction to add the lookup for
     :param block_header: The header of the block with the txn that is in the canonical chain
     :param int index: the position of the transaction in the block
     - add lookup from transaction hash to the block number and index that the body is stored at
     - remove transaction hash to body lookup in the pending pool
     """
     transaction_key = TransactionKey(block_header.block_number, index)
     self.db.set(
         make_transaction_hash_to_block_lookup_key(transaction_hash),
         rlp.encode(transaction_key),
     )
Пример #4
0
    def _add_transaction_to_canonical_chain(self, transaction_hash, block_header, index):
        """
        :param bytes transaction_hash: the hash of the transaction to add the lookup for
        :param block_header: The header of the block with the txn that is in the canonical chain
        :param int index: the position of the transaction in the block
        - add lookup from transaction hash to the block number and index that the body is stored at
        - remove transaction hash to body lookup in the pending pool
        """
        transaction_key = TransactionKey(block_header.block_number, index)
        self.db.set(
            make_transaction_hash_to_block_lookup_key(transaction_hash),
            rlp.encode(transaction_key),
        )

        # because transaction is now in canonical chain, can now remove from pending txn lookups
        lookup_key = make_transaction_hash_to_data_lookup_key(transaction_hash)
        if self.db.exists(lookup_key):
            self.db.delete(lookup_key)
Пример #5
0
    def _add_transaction_to_canonical_chain(self, transaction_hash, block_header, index):
        """
        :param bytes transaction_hash: the hash of the transaction to add the lookup for
        :param block_header: The header of the block with the txn that is in the canonical chain
        :param int index: the position of the transaction in the block
        - add lookup from transaction hash to the block number and index that the body is stored at
        - remove transaction hash to body lookup in the pending pool
        """
        transaction_key = TransactionKey(block_header.block_number, index)
        self.db.set(
            make_transaction_hash_to_block_lookup_key(transaction_hash),
            rlp.encode(transaction_key),
        )

        # because transaction is now in canonical chain, can now remove from pending txn lookups
        lookup_key = make_transaction_hash_to_data_lookup_key(transaction_hash)
        if self.db.exists(lookup_key):
            self.db.delete(lookup_key)
Пример #6
0
 def _remove_transaction_from_canonical_chain(self, transaction_hash):
     self.db.delete(make_transaction_hash_to_block_lookup_key(transaction_hash))
Пример #7
0
 def _remove_transaction_from_canonical_chain(self, transaction_hash):
     self.db.delete(make_transaction_hash_to_block_lookup_key(transaction_hash))