mirror of
https://github.com/dergigi/boris.git
synced 2025-12-18 15:14:20 +01:00
debug: add logging to relay initialization to diagnose single relay issue
This commit is contained in:
@@ -402,6 +402,8 @@ function App() {
|
||||
|
||||
// Create a relay group for better event deduplication and management
|
||||
pool.group(RELAYS)
|
||||
console.log('[relay-init] Initial pool setup - added RELAYS:', RELAYS.length, 'relays')
|
||||
console.log('[relay-init] Pool now has:', Array.from(pool.relays.keys()).length, 'relays')
|
||||
|
||||
// Load persisted accounts from localStorage
|
||||
try {
|
||||
@@ -606,6 +608,8 @@ function App() {
|
||||
|
||||
// Handle user relay list and blocked relays when account changes
|
||||
const userRelaysSub = accounts.active$.subscribe(async (account) => {
|
||||
console.log('[relay-init] userRelaysSub fired, account:', account ? 'logged in' : 'logged out')
|
||||
console.log('[relay-init] Pool has', Array.from(pool.relays.keys()).length, 'relays before applying changes')
|
||||
if (account) {
|
||||
// User logged in - load their relay list and apply it
|
||||
try {
|
||||
@@ -636,6 +640,8 @@ function App() {
|
||||
|
||||
// Apply to pool
|
||||
applyRelaySetToPool(pool, finalRelays)
|
||||
console.log('[relay-init] After applyRelaySetToPool (logged in), pool has:', Array.from(pool.relays.keys()).length, 'relays')
|
||||
console.log('[relay-init] Relay URLs:', Array.from(pool.relays.keys()))
|
||||
|
||||
// Update keep-alive subscription with new relay set
|
||||
const poolWithSub = pool as unknown as { _keepAliveSubscription?: { unsubscribe: () => void } }
|
||||
@@ -661,7 +667,10 @@ function App() {
|
||||
}
|
||||
} else {
|
||||
// User logged out - reset to hardcoded relays
|
||||
console.log('[relay-init] Applying RELAYS for logged out user, RELAYS.length:', RELAYS.length)
|
||||
applyRelaySetToPool(pool, RELAYS)
|
||||
console.log('[relay-init] After applyRelaySetToPool (logged out), pool has:', Array.from(pool.relays.keys()).length, 'relays')
|
||||
console.log('[relay-init] Relay URLs:', Array.from(pool.relays.keys()))
|
||||
|
||||
// Update keep-alive subscription
|
||||
const poolWithSub = pool as unknown as { _keepAliveSubscription?: { unsubscribe: () => void } }
|
||||
|
||||
@@ -27,8 +27,13 @@ export function applyRelaySetToPool(
|
||||
const currentUrls = new Set(Array.from(relayPool.relays.keys()))
|
||||
const targetUrls = new Set(finalUrls)
|
||||
|
||||
console.log('[relayManager] applyRelaySetToPool called')
|
||||
console.log('[relayManager] Current pool has:', currentUrls.size, 'relays')
|
||||
console.log('[relayManager] Target has:', finalUrls.length, 'relays')
|
||||
|
||||
// Add new relays
|
||||
const toAdd = finalUrls.filter(url => !currentUrls.has(url))
|
||||
console.log('[relayManager] Will add:', toAdd.length, 'relays', toAdd)
|
||||
if (toAdd.length > 0) {
|
||||
relayPool.group(toAdd)
|
||||
}
|
||||
@@ -40,6 +45,7 @@ export function applyRelaySetToPool(
|
||||
toRemove.push(url)
|
||||
}
|
||||
}
|
||||
console.log('[relayManager] Will remove:', toRemove.length, 'relays', toRemove)
|
||||
|
||||
for (const url of toRemove) {
|
||||
const relay = relayPool.relays.get(url)
|
||||
@@ -48,5 +54,7 @@ export function applyRelaySetToPool(
|
||||
relayPool.relays.delete(url)
|
||||
}
|
||||
}
|
||||
|
||||
console.log('[relayManager] After apply, pool has:', relayPool.relays.size, 'relays')
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user