Skip to content

Commit

Permalink
Shuffle replicas
Browse files Browse the repository at this point in the history
  • Loading branch information
evgeny-stakewise committed Aug 23, 2023
1 parent ff466c8 commit 19fda7d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/exits/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ async def send_signature_rotation_request_to_replicas(
) -> OracleApproval:
last_error = None

# Shuffling may help if the first endpoint is slower than others
replicas = random.sample(replicas, len(replicas))

for endpoint in replicas:
try:
return await send_signature_rotation_request(session, endpoint, payload)
Expand Down
4 changes: 4 additions & 0 deletions src/validators/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import dataclasses
import json
import logging
import random
from multiprocessing import Pool
from os import listdir
from os.path import isfile, join
Expand Down Expand Up @@ -90,6 +91,9 @@ async def send_approval_request_to_replicas(
) -> OracleApproval:
last_error = None

# Shuffling may help if the first endpoint is slower than others
replicas = random.sample(replicas, len(replicas))

for endpoint in replicas:
try:
return await send_approval_request(session, endpoint, payload)
Expand Down

0 comments on commit 19fda7d

Please sign in to comment.