Skip to content

Commit

Permalink
Rename replaceableRequest to addressPointersRequest
Browse files Browse the repository at this point in the history
  • Loading branch information
hzrd149 committed Jan 13, 2025
1 parent fcbc990 commit 68d8c03
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 8 deletions.
5 changes: 5 additions & 0 deletions .changeset/three-parents-push.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"applesauce-loaders": minor
---

Rename `replaceableRequest` to `addressPointersRequest`
6 changes: 3 additions & 3 deletions packages/loaders/src/loaders/replaceable-loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { nanoid } from "nanoid";

import { Loader } from "./loader.js";
import { generatorSequence } from "../operators/generator-sequence.js";
import { replaceableRequest } from "../operators/address-pointers-request.js";
import { addressPointersRequest } from "../operators/address-pointers-request.js";
import {
createFiltersFromAddressPointers,
getAddressPointerId,
Expand Down Expand Up @@ -90,7 +90,7 @@ function* cacheFirstSequence(
const remoteRelays = [...pointerRelays, ...defaultRelays];
if (remoteRelays.length > 0) {
log(`Requesting`, remoteRelays, remaining);
const results = yield from([remaining]).pipe(replaceableRequest(rxNostr, id, remoteRelays));
const results = yield from([remaining]).pipe(addressPointersRequest(rxNostr, id, remoteRelays));

if (handleResults(results)) return;
}
Expand All @@ -101,7 +101,7 @@ function* cacheFirstSequence(
const relays = opts.lookupRelays.filter((r) => !pointerRelays.includes(r));
if (relays.length > 0) {
log(`Request from lookup`, relays, remaining);
const results = yield from([remaining]).pipe(replaceableRequest(rxNostr, id, relays));
const results = yield from([remaining]).pipe(addressPointersRequest(rxNostr, id, relays));

if (handleResults(results)) return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { nanoid } from "nanoid";
import { Loader } from "./loader.js";
import { LoadableAddressPointer } from "./replaceable-loader.js";
import { isLoadableAddressPointer } from "../helpers/address-pointer.js";
import { replaceableRequest } from "../operators/address-pointers-request.js";
import { addressPointersRequest } from "../operators/address-pointers-request.js";

export type SingleRelayReplaceableOptions = Partial<{
/**
Expand Down Expand Up @@ -61,7 +61,7 @@ export class SingleRelayReplaceableLoader extends Loader<LoadableAddressPointer,
// batch and filter
singleRelayBatcher(opts),
// breakout the batches so they can complete
mergeMap((pointers) => from([pointers]).pipe(replaceableRequest(rxNostr, nanoid(8), [relay]))),
mergeMap((pointers) => from([pointers]).pipe(addressPointersRequest(rxNostr, nanoid(8), [relay]))),
// share the response with all subscribers
share(),
),
Expand Down
6 changes: 3 additions & 3 deletions packages/loaders/src/operators/address-pointers-request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,20 @@ import { relaysRequest } from "./relay-request.js";
import { createFiltersFromAddressPointers } from "../helpers/address-pointer.js";

/** Makes a request to relays for every set of address pointers */
export function replaceableRequest<T extends AddressPointerWithoutD>(
export function addressPointersRequest<T extends AddressPointerWithoutD>(
rxNostr: RxNostr,
id: string,
relays?: string[],
): OperatorFunction<T[], EventPacket> {
return (source) => {
const log = logger.extend(`replaceableRequest:${id}`);
const log = logger.extend(`addressPointersRequest:${id}`);

return source.pipe(
// convert pointers to filters
map(createFiltersFromAddressPointers),
// make requests
tap((filters) => {
log(`Requesting`, relays, filters);
log(`Requesting`, filters, "from", relays);
}),
// make requests
relaysRequest(rxNostr, id, relays),
Expand Down

0 comments on commit 68d8c03

Please sign in to comment.