feat: add manifest identifier fallback logging

This commit is contained in:
thePR0M3TH3AN
2025-08-03 16:28:05 -04:00
parent 30261094d2
commit 49675211e4

View File

@@ -521,12 +521,23 @@ class NostrClient:
self.keys = keys_obj self.keys = keys_obj
pubkey = self.keys.public_key() pubkey = self.keys.public_key()
identifiers = [
f"{MANIFEST_ID_PREFIX}{self.fingerprint}",
MANIFEST_ID_PREFIX.rstrip("-"),
]
timeout = timedelta(seconds=10) timeout = timedelta(seconds=10)
for ident in identifiers:
ident = f"{MANIFEST_ID_PREFIX}{self.fingerprint}"
f = Filter().author(pubkey).kind(Kind(KIND_MANIFEST)).identifier(ident).limit(1)
try:
events = (await self.client.fetch_events(f, timeout)).to_vec()
except Exception as e: # pragma: no cover - network errors
self.last_error = str(e)
logger.error(
"Failed to fetch manifest from relays %s: %s",
self.relays,
e,
)
return None
if not events:
ident = MANIFEST_ID_PREFIX.rstrip("-")
f = ( f = (
Filter() Filter()
.author(pubkey) .author(pubkey)
@@ -544,9 +555,10 @@ class NostrClient:
e, e,
) )
return None return None
if not events: if not events:
continue return None
logger.info("Fetched manifest using identifier %s", ident)
for manifest_event in events: for manifest_event in events:
try: try:
@@ -560,9 +572,7 @@ class NostrClient:
self.relays, self.relays,
e, e,
) )
# manifest was found but chunks missing; do not try other identifiers # manifest was found but chunks missing
return None
return None return None
async def fetch_latest_snapshot(self) -> Tuple[Manifest, list[bytes]] | None: async def fetch_latest_snapshot(self) -> Tuple[Manifest, list[bytes]] | None: