Skip to content

Commit f59106f

Browse files
committed
Retry on 404 with both http:// and https:// (Fix #56)
1 parent 2ff2a05 commit f59106f

File tree

4 files changed

+29
-28
lines changed

4 files changed

+29
-28
lines changed

eth_validator_watcher/beacon.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -41,17 +41,17 @@ def __init__(self, url: str) -> None:
4141
self.__http = Session()
4242
self.__nimbus_first_liveness_call = False
4343

44-
self.__http.mount(
45-
"http://",
46-
HTTPAdapter(
47-
max_retries=Retry(
48-
backoff_factor=0.5,
49-
total=3,
50-
status_forcelist=[codes.not_found],
51-
)
52-
),
44+
adapter = HTTPAdapter(
45+
max_retries=Retry(
46+
backoff_factor=0.5,
47+
total=3,
48+
status_forcelist=[codes.not_found],
49+
)
5350
)
5451

52+
self.__http.mount("http://", adapter)
53+
self.__http.mount("https://", adapter)
54+
5555
def get_genesis(self) -> Genesis:
5656
"""Get genesis data."""
5757
response = self.__http.get(f"{self.__url}/eth/v1/beacon/genesis")
@@ -67,6 +67,7 @@ def get_block(self, slot: int) -> Block:
6767
"""
6868
try:
6969
response = self.__http.get(f"{self.__url}/eth/v2/beacon/blocks/{slot}")
70+
7071
except RetryError as e:
7172
# If we are here, it means the block does not exist
7273
raise NoBlockError from e

eth_validator_watcher/execution.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,17 @@ def __init__(self, url: str) -> None:
1818
self.__url = url
1919
self.__http = Session()
2020

21-
self.__http.mount(
22-
"http://",
23-
HTTPAdapter(
24-
max_retries=Retry(
25-
backoff_factor=0.5,
26-
total=3,
27-
status_forcelist=[codes.not_found],
28-
)
29-
),
21+
adapter = HTTPAdapter(
22+
max_retries=Retry(
23+
backoff_factor=0.5,
24+
total=3,
25+
status_forcelist=[codes.not_found],
26+
)
3027
)
3128

29+
self.__http.mount("http://", adapter)
30+
self.__http.mount("https://", adapter)
31+
3232
def eth_get_block_by_hash(self, hash: str) -> ExecutionBlock:
3333
"""Get execution block.
3434

eth_validator_watcher/relays.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,17 +27,17 @@ def __init__(self, urls: list[str]) -> None:
2727
self.__urls = urls
2828
self.__http = Session()
2929

30-
self.__http.mount(
31-
"http://",
32-
HTTPAdapter(
33-
max_retries=Retry(
34-
backoff_factor=0.5,
35-
total=3,
36-
status_forcelist=[codes.not_found],
37-
)
38-
),
30+
adapter = HTTPAdapter(
31+
max_retries=Retry(
32+
backoff_factor=0.5,
33+
total=3,
34+
status_forcelist=[codes.not_found],
35+
)
3936
)
4037

38+
self.__http.mount("http://", adapter)
39+
self.__http.mount("https://", adapter)
40+
4141
def process(self, slot: int) -> None:
4242
"""Detect if the block was built by a known relay.
4343

eth_validator_watcher/slashed_validators.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ def process(
105105

106106
for index in not_our_new_exited_slashed_indexes:
107107
print(
108-
f"✂️ validator {total_exited_slashed_index_to_validator[index].pubkey[:10]} is slashed"
108+
f"✂️ validator {total_exited_slashed_index_to_validator[index].pubkey[:10]} is slashed"
109109
)
110110

111111
for index in our_new_exited_slashed_indexes:

0 commit comments

Comments
 (0)