Skip to content

Commit

Permalink
Retry on 404 with both http:// and https:// (Fix #56)
Browse files Browse the repository at this point in the history
  • Loading branch information
nalepae committed Jul 5, 2023
1 parent 2ff2a05 commit f59106f
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 28 deletions.
19 changes: 10 additions & 9 deletions eth_validator_watcher/beacon.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,17 +41,17 @@ def __init__(self, url: str) -> None:
self.__http = Session()
self.__nimbus_first_liveness_call = False

self.__http.mount(
"http://",
HTTPAdapter(
max_retries=Retry(
backoff_factor=0.5,
total=3,
status_forcelist=[codes.not_found],
)
),
adapter = HTTPAdapter(
max_retries=Retry(
backoff_factor=0.5,
total=3,
status_forcelist=[codes.not_found],
)
)

self.__http.mount("http://", adapter)
self.__http.mount("https://", adapter)

def get_genesis(self) -> Genesis:
"""Get genesis data."""
response = self.__http.get(f"{self.__url}/eth/v1/beacon/genesis")
Expand All @@ -67,6 +67,7 @@ def get_block(self, slot: int) -> Block:
"""
try:
response = self.__http.get(f"{self.__url}/eth/v2/beacon/blocks/{slot}")

except RetryError as e:
# If we are here, it means the block does not exist
raise NoBlockError from e
Expand Down
18 changes: 9 additions & 9 deletions eth_validator_watcher/execution.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,17 @@ def __init__(self, url: str) -> None:
self.__url = url
self.__http = Session()

self.__http.mount(
"http://",
HTTPAdapter(
max_retries=Retry(
backoff_factor=0.5,
total=3,
status_forcelist=[codes.not_found],
)
),
adapter = HTTPAdapter(
max_retries=Retry(
backoff_factor=0.5,
total=3,
status_forcelist=[codes.not_found],
)
)

self.__http.mount("http://", adapter)
self.__http.mount("https://", adapter)

def eth_get_block_by_hash(self, hash: str) -> ExecutionBlock:
"""Get execution block.
Expand Down
18 changes: 9 additions & 9 deletions eth_validator_watcher/relays.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,17 @@ def __init__(self, urls: list[str]) -> None:
self.__urls = urls
self.__http = Session()

self.__http.mount(
"http://",
HTTPAdapter(
max_retries=Retry(
backoff_factor=0.5,
total=3,
status_forcelist=[codes.not_found],
)
),
adapter = HTTPAdapter(
max_retries=Retry(
backoff_factor=0.5,
total=3,
status_forcelist=[codes.not_found],
)
)

self.__http.mount("http://", adapter)
self.__http.mount("https://", adapter)

def process(self, slot: int) -> None:
"""Detect if the block was built by a known relay.
Expand Down
2 changes: 1 addition & 1 deletion eth_validator_watcher/slashed_validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ def process(

for index in not_our_new_exited_slashed_indexes:
print(
f"✂️ validator {total_exited_slashed_index_to_validator[index].pubkey[:10]} is slashed"
f"✂️ validator {total_exited_slashed_index_to_validator[index].pubkey[:10]} is slashed"
)

for index in our_new_exited_slashed_indexes:
Expand Down

0 comments on commit f59106f

Please sign in to comment.