chore: Update logging and configuration in market-related files

- Enhance logging in useMarket and NostrClient to provide better insights during event fetching and market loading.
- Add local relay support in configuration for improved development and testing.
- Adjust delay in event fetching to ensure more reliable data collection from relays.
This commit is contained in:
padreug 2025-08-02 17:46:19 +02:00
parent 54044f165c
commit e66d976ee8
3 changed files with 8 additions and 2 deletions

View file

@ -146,6 +146,8 @@ export function useMarket() {
console.log('Loading stalls for market pubkey:', marketPubkey) console.log('Loading stalls for market pubkey:', marketPubkey)
// Fetch stall events for this market // Fetch stall events for this market
// Note: We need to fetch all stalls and then filter by the ones that belong to this market
// since stalls don't have a direct market association in their tags
const events = await client.fetchEvents({ const events = await client.fetchEvents({
kinds: [MARKET_EVENT_KINDS.STALL], kinds: [MARKET_EVENT_KINDS.STALL],
authors: [marketPubkey] authors: [marketPubkey]

View file

@ -62,6 +62,7 @@ export const config: AppConfig = {
market: { market: {
defaultNaddr: import.meta.env.VITE_MARKET_NADDR || '', defaultNaddr: import.meta.env.VITE_MARKET_NADDR || '',
supportedRelays: parseJsonEnv(import.meta.env.VITE_MARKET_RELAYS, [ supportedRelays: parseJsonEnv(import.meta.env.VITE_MARKET_RELAYS, [
'ws://127.0.0.1:7777',
'wss://relay.damus.io', 'wss://relay.damus.io',
'wss://relay.snort.social', 'wss://relay.snort.social',
'wss://nostr-pub.wellorder.net', 'wss://nostr-pub.wellorder.net',

View file

@ -261,20 +261,23 @@ export class NostrClient {
const relayResults = await Promise.allSettled( const relayResults = await Promise.allSettled(
this.relays.map(async (relay) => { this.relays.map(async (relay) => {
try { try {
console.log(`Fetching from relay: ${relay}`)
const relayEvents: Event[] = [] const relayEvents: Event[] = []
const subscription = this.pool.subscribeMany([relay], filters, { const subscription = this.pool.subscribeMany([relay], filters, {
onevent(event: Event) { onevent(event: Event) {
console.log(`Received event from ${relay}:`, event)
relayEvents.push(event) relayEvents.push(event)
}, },
oneose() { oneose() {
// End of stored events console.log(`End of stored events from ${relay}`)
} }
}) })
// Wait for events to be collected // Wait for events to be collected
await new Promise(resolve => setTimeout(resolve, 1000)) await new Promise(resolve => setTimeout(resolve, 2000))
subscription.close() subscription.close()
console.log(`Found ${relayEvents.length} events from ${relay}`)
return relayEvents return relayEvents
} catch (error) { } catch (error) {
console.warn(`Failed to fetch from relay ${relay}:`, error) console.warn(`Failed to fetch from relay ${relay}:`, error)