chia-blockchain/chia/util/prev_transaction_block.py
Kyle Altendorf 3b084a165b
configure isort to add the future annotations import (#13327)
* configure isort to add the future annotations import

* apply the new isort setting

* remove type ignores for new mypy (#13539)

https://pypi.org/project/mypy/0.981/

* another
2022-09-30 03:40:22 -05:00

24 lines
712 B
Python

from __future__ import annotations
from typing import Tuple
from chia.consensus.block_record import BlockRecord
from chia.consensus.blockchain_interface import BlockchainInterface
from chia.util.ints import uint128
def get_prev_transaction_block(
curr: BlockRecord,
blocks: BlockchainInterface,
total_iters_sp: uint128,
) -> Tuple[bool, BlockRecord]:
prev_transaction_block = curr
while not curr.is_transaction_block:
curr = blocks.block_record(curr.prev_hash)
if total_iters_sp > curr.total_iters:
prev_transaction_block = curr
is_transaction_block = True
else:
is_transaction_block = False
return is_transaction_block, prev_transaction_block