Add getTransactionKey

This commit is contained in:
coffeepots 2018-08-17 19:52:48 +01:00
parent 691adf0e23
commit be0f77870c
1 changed files with 5 additions and 0 deletions

View File

@ -113,6 +113,11 @@ iterator getBlockTransactionHashes(self: BaseChainDB, blockHeader: BlockHeader):
# for encoded_transaction in all_encoded_transactions:
# yield keccak(encoded_transaction)
proc getTransactionKey*(self: BaseChainDB, transactionHash: Hash256): tuple[blockNumber: BlockNumber, index: int] {.inline.} =
let
tx = self.db.get(transactionHashToBlockKey(transactionHash).toOpenArray).toRange
key = rlp.decode(tx, TransactionKey)
return (key.blockNumber, key.index)
proc removeTransactionFromCanonicalChain(self: BaseChainDB, transactionHash: Hash256) {.inline.} =
## Removes the transaction specified by the given hash from the canonical chain.