rpc connection bugfix
This commit is contained in:
@@ -206,17 +206,22 @@ async def archive_intercept_middleware(make_request, w3):
|
||||
# Only intercept relevant methods
|
||||
expected_args = ARCHIVE_METHODS.get(method,-1)
|
||||
is_archive_method = len(params) == expected_args
|
||||
block_height = None
|
||||
if is_archive_method:
|
||||
block_identifier = params[-1]
|
||||
block_identifier = int(block_identifier, 16) if type(block_identifier) is str else int(params[-1]) # we don't expect hex strings
|
||||
if block_identifier <= w3.archive_fault_height:
|
||||
# this block is at least as old as another block that already failed to fetch history from this RPC
|
||||
raise ArchiveException(method, block_identifier)
|
||||
if block_identifier != 'latest':
|
||||
block_identifier = int(block_identifier, 16) if type(block_identifier) is str else int(params[-1])
|
||||
if block_identifier <= w3.archive_fault_height:
|
||||
# this block is at least as old as another block that already failed to fetch history from this RPC
|
||||
raise ArchiveException(method, block_identifier)
|
||||
resp = await make_request(method, params)
|
||||
if is_archive_method and 'error' in resp and resp['error']['code'] in ARCHIVE_ERRORS:
|
||||
# noinspection PyUnboundLocalVariable
|
||||
w3.archive_fault_height = max(w3.archive_fault_height, block_identifier)
|
||||
raise ArchiveException(method, block_identifier)
|
||||
if block_height is None:
|
||||
# noinspection PyUnboundLocalVariable
|
||||
raise Exception(f'Got an archive fault using a block_identifier of {block_identifier}')
|
||||
# noinspection PyTypeChecker
|
||||
w3.archive_fault_height = max(w3.archive_fault_height, block_height)
|
||||
raise ArchiveException(method, block_height)
|
||||
resp = await make_request(method, params)
|
||||
return resp
|
||||
|
||||
@@ -305,7 +310,6 @@ class RetryHTTPProvider (AsyncHTTPProvider):
|
||||
try:
|
||||
async with self.in_flight:
|
||||
await self.rate_allowed.wait()
|
||||
log.debug(f'Requesting RPC call {method}')
|
||||
return await super().make_request(method, params)
|
||||
except ClientResponseError as e:
|
||||
if e.status != 429:
|
||||
|
||||
Reference in New Issue
Block a user