mirror of
https://github.com/dergigi/boris.git
synced 2026-01-01 05:54:37 +01:00
refactor: remove concurrent decryption in favor of sequential
Removed mapWithConcurrency hack: - Simpler code with plain for loop - More predictable behavior - Better for bunker signers (network round-trips) - Each decrypt happens in order, no race conditions Sequential processing is cleaner and works better with remote signers.
This commit is contained in:
@@ -5,7 +5,7 @@ import {
|
||||
} from '../types/bookmarks'
|
||||
import { BookmarkHiddenSymbol, hasNip04Decrypt, hasNip44Decrypt, processApplesauceBookmarks } from './bookmarkHelpers'
|
||||
import type { NostrEvent } from './bookmarkHelpers'
|
||||
import { mapWithConcurrency, withTimeout } from '../utils/async'
|
||||
import { withTimeout } from '../utils/async'
|
||||
|
||||
type DecryptFn = (pubkey: string, content: string) => Promise<string>
|
||||
type UnlockHiddenTagsFn = typeof Helpers.unlockHiddenTags
|
||||
@@ -193,19 +193,15 @@ export async function collectBookmarksFromEvents(
|
||||
}
|
||||
}
|
||||
|
||||
// Run decrypt jobs with limited concurrency (6 parallel at most)
|
||||
// Decrypt events sequentially
|
||||
const privateItemsAll: IndividualBookmark[] = []
|
||||
if (decryptJobs.length > 0 && signerCandidate) {
|
||||
const privateChunks = await mapWithConcurrency(
|
||||
decryptJobs,
|
||||
6,
|
||||
async (job) => decryptEvent(job.evt, activeAccount, signerCandidate, job.metadata)
|
||||
)
|
||||
privateChunks.forEach(chunk => {
|
||||
if (chunk && chunk.length > 0) {
|
||||
privateItemsAll.push(...chunk)
|
||||
for (const job of decryptJobs) {
|
||||
const privateItems = await decryptEvent(job.evt, activeAccount, signerCandidate, job.metadata)
|
||||
if (privateItems && privateItems.length > 0) {
|
||||
privateItemsAll.push(...privateItems)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
return { publicItemsAll, privateItemsAll, newestCreatedAt, latestContent, allTags }
|
||||
|
||||
Reference in New Issue
Block a user