Skip to content

Commit

Permalink
[#] solana, sns.id with cache
Browse files Browse the repository at this point in the history
  • Loading branch information
ZhongFuze committed Nov 7, 2024
1 parent 40a7f98 commit a3d4fca
Show file tree
Hide file tree
Showing 5 changed files with 693 additions and 45 deletions.
10 changes: 7 additions & 3 deletions src/resolver/ethereum.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
Author: Zella Zhong
Date: 2024-10-06 18:41:34
LastEditors: Zella Zhong
LastEditTime: 2024-10-30 15:10:26
LastEditTime: 2024-11-07 23:24:00
FilePath: /data_service/src/resolver/ethereum.py
Description:
'''
Expand Down Expand Up @@ -654,17 +654,21 @@ async def query_and_update_missing_query_ids(query_ids):
return identity_records

def filter_ethereum_query_ids(identities):
cnt = 0
final_query_ids = set()
for identity in identities:
cnt += 1
is_evm = is_ethereum_address(identity)
if is_evm:
final_query_ids.add(f"{Platform.ethereum.value},{identity}")
if cnt > QUERY_MAX_LIMIT:
break

return list(final_query_ids)

async def query_ethereum_profile_by_ids_cache(info, identities, require_cache=False):
if len(identities) > QUERY_MAX_LIMIT:
return ExceedRangeInput(QUERY_MAX_LIMIT)
# if len(identities) > QUERY_MAX_LIMIT:
# return ExceedRangeInput(QUERY_MAX_LIMIT)

filter_query_ids = filter_ethereum_query_ids(identities)
if len(filter_query_ids) == 0:
Expand Down
17 changes: 7 additions & 10 deletions src/resolver/fetch.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
Author: Zella Zhong
Date: 2024-10-06 19:05:41
LastEditors: Zella Zhong
LastEditTime: 2024-11-07 21:05:51
LastEditTime: 2024-11-08 00:15:19
FilePath: /data_service/src/resolver/fetch.py
Description:
'''
Expand Down Expand Up @@ -51,6 +51,7 @@
from resolver.unstoppabledomains import query_unstoppabledomains_profile_by_ids_cache
from resolver.basenames import query_basenames_profile_by_ids_cache
from resolver.sns import query_sns_profile_by_ids_cache
from resolver.solana import query_solana_profile_by_ids_cache

async def single_fetch(info, platform, identity):
identity_records = []
Expand All @@ -68,10 +69,9 @@ async def single_fetch(info, platform, identity):
# return await query_profile_by_single_lens_handle(info, identity)
identity_records = await query_lens_profile_by_ids_cache(info, [identity], require_cache=True)
elif platform == Platform.solana:
record = await query_profile_by_single_solana(info, identity)
identity_records.append(record)
identity_records = await query_solana_profile_by_ids_cache(info, [identity], require_cache=True)
elif platform == Platform.sns:
identity_records = await query_sns_profile_by_ids_cache(info, [identity], require_cache=False)
identity_records = await query_sns_profile_by_ids_cache(info, [identity], require_cache=True)
elif platform == Platform.clusters:
record = await query_profile_by_single_clusters(info, identity)
identity_records.append(record)
Expand Down Expand Up @@ -255,24 +255,21 @@ async def batch_fetch_all(info, vertices_map):
return PlatformNotSupport(platform)

if platform_enum == Platform.ethereum:
# tasks.append(query_profile_by_addresses(info, identities))
tasks.append(query_ethereum_profile_by_ids_cache(info, identities, require_cache=True))
elif platform_enum == Platform.ens:
# tasks.append(query_profile_by_ensnames(info, identities))
tasks.append(query_ensname_profile_by_ids_cache(info, identities, require_cache=True))
elif platform_enum == Platform.farcaster:
# tasks.append(query_profile_by_fnames(info, identities))
tasks.append(query_farcaster_profile_by_ids_cache(info, identities, require_cache=True))
elif platform_enum == Platform.lens:
# tasks.append(query_profile_by_lens_handle(info, identities))
tasks.append(query_lens_profile_by_ids_cache(info, identities, require_cache=True))
elif platform_enum == Platform.clusters:
tasks.append(query_profile_by_batch_clusters(info, identities))
elif platform_enum == Platform.basenames:
# tasks.append(query_profile_by_basenames(info, identities))
tasks.append(query_basenames_profile_by_ids_cache(info, identities, require_cache=True))
elif platform_enum == Platform.sns:
tasks.append(query_sns_profile_by_ids_cache(info, identities, require_cache=True))
elif platform_enum == Platform.solana:
tasks.append(query_profile_by_solana_addresses(info, identities))
tasks.append(query_solana_profile_by_ids_cache(info, identities, require_cache=True))
elif platform_enum == Platform.unstoppabledomains:
tasks.append(query_unstoppabledomains_profile_by_ids_cache(info, identities, require_cache=True))
elif platform_enum == Platform.bitcoin:
Expand Down
Loading

0 comments on commit a3d4fca

Please sign in to comment.