Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OCT-2055: Add caching for antisybil #559

Merged
merged 2 commits into from
Nov 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import requests

from app.extensions import cache
from app.constants import GC_PASSPORT_SCORER_API
from app.exceptions import ExternalApiException
from app.infrastructure.exception_handler import ExceptionHandler
Expand Down Expand Up @@ -29,6 +30,7 @@ def _get_issue_address_for_scoring_url() -> str:
return f"{GC_PASSPORT_SCORER_API}/registry/submit-passport"


@cache.memoize(timeout=1)
def issue_address_for_scoring(address: str) -> dict:
try:
response = requests.post(
Expand All @@ -48,6 +50,7 @@ def _get_fetch_score_url(scorer_id: str, address: str) -> str:
return f"{GC_PASSPORT_SCORER_API}/registry/score/{scorer_id}/{address}"


@cache.memoize(timeout=1)
def fetch_score(address: str) -> dict:
try:
response = requests.get(
Expand Down
3 changes: 2 additions & 1 deletion backend/app/modules/user/antisybil/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ def _has_guest_stamp_applied_by_gp(score: GPStamps) -> bool:


def _apply_gtc_staking_stamp_nullification(score: int, stamps: GPStamps) -> int:
"Take score and stamps as returned by Passport and remove score associated with GTC staking"
"""Take score and stamps as returned by Passport and remove score associated with GTC staking"""

delta = 0
all_stamps = json.loads(stamps.stamps)
providers = [_get_provider(stamp) for stamp in all_stamps]
Expand Down