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:
parent
54044f165c
commit
e66d976ee8
3 changed files with 8 additions and 2 deletions
|
|
@ -146,6 +146,8 @@ export function useMarket() {
|
|||
console.log('Loading stalls for market pubkey:', marketPubkey)
|
||||
|
||||
// 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({
|
||||
kinds: [MARKET_EVENT_KINDS.STALL],
|
||||
authors: [marketPubkey]
|
||||
|
|
|
|||
|
|
@ -62,6 +62,7 @@ export const config: AppConfig = {
|
|||
market: {
|
||||
defaultNaddr: import.meta.env.VITE_MARKET_NADDR || '',
|
||||
supportedRelays: parseJsonEnv(import.meta.env.VITE_MARKET_RELAYS, [
|
||||
'ws://127.0.0.1:7777',
|
||||
'wss://relay.damus.io',
|
||||
'wss://relay.snort.social',
|
||||
'wss://nostr-pub.wellorder.net',
|
||||
|
|
|
|||
|
|
@ -261,20 +261,23 @@ export class NostrClient {
|
|||
const relayResults = await Promise.allSettled(
|
||||
this.relays.map(async (relay) => {
|
||||
try {
|
||||
console.log(`Fetching from relay: ${relay}`)
|
||||
const relayEvents: Event[] = []
|
||||
const subscription = this.pool.subscribeMany([relay], filters, {
|
||||
onevent(event: Event) {
|
||||
console.log(`Received event from ${relay}:`, event)
|
||||
relayEvents.push(event)
|
||||
},
|
||||
oneose() {
|
||||
// End of stored events
|
||||
console.log(`End of stored events from ${relay}`)
|
||||
}
|
||||
})
|
||||
|
||||
// Wait for events to be collected
|
||||
await new Promise(resolve => setTimeout(resolve, 1000))
|
||||
await new Promise(resolve => setTimeout(resolve, 2000))
|
||||
subscription.close()
|
||||
|
||||
console.log(`Found ${relayEvents.length} events from ${relay}`)
|
||||
return relayEvents
|
||||
} catch (error) {
|
||||
console.warn(`Failed to fetch from relay ${relay}:`, error)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue