Skip to content

Commit

Permalink
[PAY-2220] Use slot_diff in user_bank health (#6799)
Browse files Browse the repository at this point in the history
  • Loading branch information
dharit-tan authored Nov 28, 2023
1 parent 12f39f1 commit 9ddbf19
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
10 changes: 5 additions & 5 deletions packages/discovery-provider/src/queries/get_health.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ class GetHealthArgs(TypedDict):
# Number of seconds rewards manager txs are allowed to drift
rewards_manager_max_drift: Optional[int]
# Number of seconds user bank txs are allowed to drift
user_bank_max_drift: Optional[int]
user_bank_max_slot_diff: Optional[int]
# Number of seconds user bank txs are allowed to drift
spl_audio_max_drift: Optional[int]

Expand All @@ -200,7 +200,7 @@ def get_health(args: GetHealthArgs, use_redis_cache: bool = True) -> Tuple[Dict,
reactions_max_last_reaction_drift = args.get("reactions_max_last_reaction_drift")
plays_count_max_drift = args.get("plays_count_max_drift")
rewards_manager_max_drift = args.get("rewards_manager_max_drift")
user_bank_max_drift = args.get("user_bank_max_drift")
user_bank_max_slot_diff = args.get("user_bank_max_slot_diff")
spl_audio_max_drift = args.get("spl_audio_max_drift")

errors = []
Expand Down Expand Up @@ -259,7 +259,7 @@ def get_health(args: GetHealthArgs, use_redis_cache: bool = True) -> Tuple[Dict,
rewards_manager_health_info = get_rewards_manager_health_info(
redis, rewards_manager_max_drift
)
user_bank_health_info = get_user_bank_health_info(redis, user_bank_max_drift)
user_bank_health_info = get_user_bank_health_info(redis, user_bank_max_slot_diff)
spl_audio_info = get_spl_audio_info(redis, spl_audio_max_drift)
reactions_health_info = get_reactions_health_info(
redis,
Expand Down Expand Up @@ -613,7 +613,7 @@ def get_play_health_info(


def get_user_bank_health_info(
redis: Redis, max_drift: Optional[int] = None
redis: Redis, max_slot_diff: Optional[int] = None
) -> SolHealthInfo:
if redis is None:
raise Exception("Invalid arguments for get_user_bank_health_info")
Expand All @@ -622,7 +622,7 @@ def get_user_bank_health_info(

tx_health_info = get_sol_user_bank_health_info(redis, current_time_utc)
# If user bank indexing max drift provided, perform comparison
is_unhealthy = bool(max_drift and max_drift < tx_health_info["time_diff"])
is_unhealthy = bool(max_slot_diff and max_slot_diff < tx_health_info["slot_diff"])

return {
"is_unhealthy": is_unhealthy,
Expand Down
4 changes: 3 additions & 1 deletion packages/discovery-provider/src/queries/health_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,9 @@ def health_check():
"rewards_manager_max_drift": request.args.get(
"rewards_manager_max_drift", type=int
),
"user_bank_max_drift": request.args.get("user_bank_max_drift", type=int),
"user_bank_max_slot_diff": request.args.get(
"user_bank_max_slot_diff", type=int
),
"spl_audio_max_drift": request.args.get("spl_audio_max_drift", type=int),
}
try:
Expand Down

0 comments on commit 9ddbf19

Please sign in to comment.