MCPcopy Create free account
hub / github.com/block/buzz / fetchChunkedAuxEvents

Method fetchChunkedAuxEvents

desktop/src/shared/api/relayClientSession.ts:201–226  ·  view source on GitHub ↗
(
    channelId: string,
    eventIds: string[],
    buildFilter: (
      channelId: string,
      eventIds: string[],
    ) => RelaySubscriptionFilter,
  )

Source from the content-addressed store, hash-verified

199 }
200
201 private async fetchChunkedAuxEvents(
202 channelId: string,
203 eventIds: string[],
204 buildFilter: (
205 channelId: string,
206 eventIds: string[],
207 ) => RelaySubscriptionFilter,
208 ): Promise<RelayEvent[]> {
209 if (eventIds.length === 0) {
210 return [];
211 }
212
213 await this.ensureConnected();
214
215 const chunks: string[][] = [];
216 for (let i = 0; i < eventIds.length; i += AUX_BACKFILL_CHUNK_SIZE) {
217 chunks.push(eventIds.slice(i, i + AUX_BACKFILL_CHUNK_SIZE));
218 }
219
220 const batches: RelayEvent[][] = [];
221 for (const ids of chunks) {
222 batches.push(await this.requestHistory(buildFilter(channelId, ids)));
223 }
224
225 return batches.flat();
226 }
227
228 private async fetchHistory(filter: RelaySubscriptionFilter) {
229 await this.ensureConnected();

Calls 3

ensureConnectedMethod · 0.95
requestHistoryMethod · 0.95
pushMethod · 0.80

Tested by

no test coverage detected