Pass w3 into create block
This commit is contained in:
parent
9d364b5804
commit
ae2c9886db
@ -11,10 +11,9 @@ cache_directory = "./cache"
|
|||||||
|
|
||||||
|
|
||||||
def create_from_block_number(
|
def create_from_block_number(
|
||||||
block_number: int, base_provider, should_cache: bool
|
base_provider, w3: Web3, block_number: int, should_cache: bool
|
||||||
) -> Block:
|
) -> Block:
|
||||||
if not should_cache:
|
if not should_cache:
|
||||||
w3 = Web3(base_provider)
|
|
||||||
return fetch_block(w3, base_provider, block_number)
|
return fetch_block(w3, base_provider, block_number)
|
||||||
|
|
||||||
cache_path = _get_cache_path(block_number)
|
cache_path = _get_cache_path(block_number)
|
||||||
@ -26,7 +25,6 @@ def create_from_block_number(
|
|||||||
else:
|
else:
|
||||||
print(f"Cache for block {block_number} did not exist, getting data")
|
print(f"Cache for block {block_number} did not exist, getting data")
|
||||||
|
|
||||||
w3 = Web3(base_provider)
|
|
||||||
block = fetch_block(w3, base_provider, block_number)
|
block = fetch_block(w3, base_provider, block_number)
|
||||||
|
|
||||||
cache_block(cache_path, block)
|
cache_block(cache_path, block)
|
||||||
|
@ -33,11 +33,12 @@ def cli():
|
|||||||
@click.option("--cache/--no-cache", default=True)
|
@click.option("--cache/--no-cache", default=True)
|
||||||
def inspect_block(block_number: int, rpc: str, cache: bool):
|
def inspect_block(block_number: int, rpc: str, cache: bool):
|
||||||
base_provider = Web3.HTTPProvider(rpc)
|
base_provider = Web3.HTTPProvider(rpc)
|
||||||
|
w3 = Web3(base_provider)
|
||||||
|
|
||||||
if not cache:
|
if not cache:
|
||||||
click.echo("Skipping cache")
|
click.echo("Skipping cache")
|
||||||
|
|
||||||
_inspect_block(base_provider, block_number, should_cache=cache)
|
_inspect_block(base_provider, w3, block_number, should_cache=cache)
|
||||||
|
|
||||||
|
|
||||||
@cli.command()
|
@cli.command()
|
||||||
@ -47,6 +48,7 @@ def inspect_block(block_number: int, rpc: str, cache: bool):
|
|||||||
@click.option("--cache/--no-cache", default=True)
|
@click.option("--cache/--no-cache", default=True)
|
||||||
def inspect_many_blocks(after_block: int, before_block: int, rpc: str, cache: bool):
|
def inspect_many_blocks(after_block: int, before_block: int, rpc: str, cache: bool):
|
||||||
base_provider = Web3.HTTPProvider(rpc)
|
base_provider = Web3.HTTPProvider(rpc)
|
||||||
|
w3 = Web3(base_provider)
|
||||||
|
|
||||||
if not cache:
|
if not cache:
|
||||||
click.echo("Skipping cache")
|
click.echo("Skipping cache")
|
||||||
@ -62,6 +64,7 @@ def inspect_many_blocks(after_block: int, before_block: int, rpc: str, cache: bo
|
|||||||
|
|
||||||
_inspect_block(
|
_inspect_block(
|
||||||
base_provider,
|
base_provider,
|
||||||
|
w3,
|
||||||
block_number,
|
block_number,
|
||||||
should_print_stats=False,
|
should_print_stats=False,
|
||||||
should_write_classified_traces=False,
|
should_write_classified_traces=False,
|
||||||
@ -71,17 +74,17 @@ def inspect_many_blocks(after_block: int, before_block: int, rpc: str, cache: bo
|
|||||||
|
|
||||||
def _inspect_block(
|
def _inspect_block(
|
||||||
base_provider,
|
base_provider,
|
||||||
|
w3: Web3,
|
||||||
block_number: int,
|
block_number: int,
|
||||||
should_cache: bool,
|
should_cache: bool,
|
||||||
should_print_stats: bool = True,
|
should_print_stats: bool = True,
|
||||||
should_write_classified_traces: bool = True,
|
should_write_classified_traces: bool = True,
|
||||||
should_write_swaps: bool = True,
|
should_write_swaps: bool = True,
|
||||||
should_write_arbitrages: bool = True,
|
should_write_arbitrages: bool = True,
|
||||||
should_print_miner_payments: bool = False,
|
should_print_miner_payments: bool = True,
|
||||||
):
|
):
|
||||||
|
|
||||||
block_data = block.create_from_block_number(
|
block_data = block.create_from_block_number(
|
||||||
block_number, base_provider, should_cache
|
base_provider, w3, block_number, should_cache
|
||||||
)
|
)
|
||||||
|
|
||||||
click.echo(f"Total traces: {len(block_data.traces)}")
|
click.echo(f"Total traces: {len(block_data.traces)}")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user