From 54d60bc6742349e4759708a35292079cddee74c2 Mon Sep 17 00:00:00 2001 From: Luke Van Seters Date: Mon, 13 Sep 2021 18:34:40 -0400 Subject: [PATCH] Create cache dir if not exists --- mev_inspect/block.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/mev_inspect/block.py b/mev_inspect/block.py index d1dbee7..dca522d 100644 --- a/mev_inspect/block.py +++ b/mev_inspect/block.py @@ -70,6 +70,8 @@ def get_transaction_hashes(calls: List[Trace]) -> List[str]: def cache_block(cache_path: Path, block: Block): write_mode = "w" if cache_path.is_file() else "x" + cache_path.parent.mkdir(parents=True, exist_ok=True) + with open(cache_path, mode=write_mode) as cache_file: cache_file.write(block.json())