Onionr/src/blockdb/__init__.py

17 lines
454 B
Python
Raw Normal View History

2022-02-03 06:32:26 +00:00
from typing import Generator
from onionrblocks import Block
import db
from .. import identifyhome
block_db_path = identifyhome.identify_home() + 'blocks.db'
def get_blocks_by_type(block_type) -> Generator[Block]:
block_db = db.get_db_obj(block_db_path, 'u')
for block_hash in db.list_keys(block_db_path):
block = Block(block_hash, block_db[block_hash], auto_verify=False)
if block.type == block_type:
yield block