@bsv/sdk 1.7.1 → 1.7.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,7 @@
1
1
  import { Transaction } from '../transaction/index.js';
2
2
  import OverlayAdminTokenTemplate from './OverlayAdminTokenTemplate.js';
3
+ // Only bind window.fetch in the browser
4
+ const defaultFetch = typeof window !== 'undefined' ? fetch.bind(window) : fetch;
3
5
  /** Default SLAP trackers */
4
6
  export const DEFAULT_SLAP_TRACKERS = [
5
7
  // BSVA clusters
@@ -23,7 +25,7 @@ const MAX_TRACKER_WAIT_TIME = 5000;
23
25
  export class HTTPSOverlayLookupFacilitator {
24
26
  fetchClient;
25
27
  allowHTTP;
26
- constructor(httpClient = fetch, allowHTTP = false) {
28
+ constructor(httpClient = defaultFetch, allowHTTP = false) {
27
29
  this.fetchClient = httpClient;
28
30
  this.allowHTTP = allowHTTP;
29
31
  }
@@ -31,31 +33,38 @@ export class HTTPSOverlayLookupFacilitator {
31
33
  if (!url.startsWith('https:') && !this.allowHTTP) {
32
34
  throw new Error('HTTPS facilitator can only use URLs that start with "https:"');
33
35
  }
34
- const timeoutPromise = new Promise((resolve, reject) => setTimeout(() => reject(new Error('Request timed out')), timeout));
35
- const fetchPromise = fetch(`${url}/lookup`, {
36
- method: 'POST',
37
- headers: {
38
- 'Content-Type': 'application/json'
39
- },
40
- body: JSON.stringify({
41
- service: question.service,
42
- query: question.query
43
- })
44
- });
45
- const response = (await Promise.race([
46
- fetchPromise,
47
- timeoutPromise
48
- ]));
49
- if (response.ok) {
36
+ const controller = typeof AbortController !== 'undefined' ? new AbortController() : undefined;
37
+ const timer = setTimeout(() => {
38
+ try {
39
+ controller?.abort();
40
+ }
41
+ catch { /* noop */ }
42
+ }, timeout);
43
+ try {
44
+ const fco = {
45
+ method: 'POST',
46
+ headers: { 'Content-Type': 'application/json' },
47
+ body: JSON.stringify({ service: question.service, query: question.query }),
48
+ signal: controller?.signal
49
+ };
50
+ const response = await this.fetchClient(`${url}/lookup`, fco);
51
+ if (!response.ok)
52
+ throw new Error(`Failed to facilitate lookup (HTTP ${response.status})`);
50
53
  return await response.json();
51
54
  }
52
- else {
53
- throw new Error('Failed to facilitate lookup');
55
+ catch (e) {
56
+ // Normalize timeouts to a consistent error message
57
+ if (e?.name === 'AbortError')
58
+ throw new Error('Request timed out');
59
+ throw e;
60
+ }
61
+ finally {
62
+ clearTimeout(timer);
54
63
  }
55
64
  }
56
65
  }
57
66
  /**
58
- * Represents an SHIP transaction broadcaster.
67
+ * Represents a Lookup Resolver.
59
68
  */
60
69
  export default class LookupResolver {
61
70
  facilitator;
@@ -63,12 +72,26 @@ export default class LookupResolver {
63
72
  hostOverrides;
64
73
  additionalHosts;
65
74
  networkPreset;
75
+ // ---- Caches / memoization ----
76
+ hostsCache;
77
+ hostsInFlight;
78
+ hostsTtlMs;
79
+ hostsMaxEntries;
80
+ txMemo;
81
+ txMemoTtlMs;
66
82
  constructor(config = {}) {
67
83
  this.networkPreset = config.networkPreset ?? 'mainnet';
68
84
  this.facilitator = config.facilitator ?? new HTTPSOverlayLookupFacilitator(undefined, this.networkPreset === 'local');
69
85
  this.slapTrackers = config.slapTrackers ?? (this.networkPreset === 'mainnet' ? DEFAULT_SLAP_TRACKERS : DEFAULT_TESTNET_SLAP_TRACKERS);
70
86
  this.hostOverrides = config.hostOverrides ?? {};
71
87
  this.additionalHosts = config.additionalHosts ?? {};
88
+ // cache tuning
89
+ this.hostsTtlMs = config.cache?.hostsTtlMs ?? 5 * 60 * 1000; // 5 min
90
+ this.hostsMaxEntries = config.cache?.hostsMaxEntries ?? 128;
91
+ this.txMemoTtlMs = config.cache?.txMemoTtlMs ?? 10 * 60 * 1000; // 10 min
92
+ this.hostsCache = new Map();
93
+ this.hostsInFlight = new Map();
94
+ this.txMemo = new Map();
72
95
  }
73
96
  /**
74
97
  * Given a LookupQuestion, returns a LookupAnswer. Aggregates across multiple services and supports resiliency.
@@ -85,53 +108,119 @@ export default class LookupResolver {
85
108
  competentHosts = ['http://localhost:8080'];
86
109
  }
87
110
  else {
88
- competentHosts = await this.findCompetentHosts(question.service);
111
+ competentHosts = await this.getCompetentHostsCached(question.service);
89
112
  }
90
113
  if (this.additionalHosts[question.service]?.length > 0) {
91
- competentHosts = [
92
- ...competentHosts,
93
- ...this.additionalHosts[question.service]
94
- ];
114
+ // preserve order: resolved hosts first, then additional (unique)
115
+ const extra = this.additionalHosts[question.service];
116
+ const seen = new Set(competentHosts);
117
+ for (const h of extra)
118
+ if (!seen.has(h))
119
+ competentHosts.push(h);
95
120
  }
96
121
  if (competentHosts.length < 1) {
97
122
  throw new Error(`No competent ${this.networkPreset} hosts found by the SLAP trackers for lookup service: ${question.service}`);
98
123
  }
99
- // Use Promise.allSettled to handle individual host failures
100
- const hostResponses = await Promise.allSettled(competentHosts.map(async (host) => await this.facilitator.lookup(host, question, timeout)));
101
- const successfulResponses = hostResponses
102
- .filter((result) => result.status === 'fulfilled')
103
- .map((result) => result.value);
104
- if (successfulResponses.length === 0) {
105
- throw new Error('No successful responses from any hosts');
106
- }
107
- // Process the successful responses
108
- // Aggregate outputs from all successful responses
109
- const outputs = new Map();
110
- for (const response of successfulResponses) {
111
- if (response.type !== 'output-list') {
124
+ // Fire all hosts with per-host timeout, harvest successful output-list responses
125
+ const hostResponses = await Promise.allSettled(competentHosts.map(async (host) => {
126
+ return await this.facilitator.lookup(host, question, timeout);
127
+ }));
128
+ const outputsMap = new Map();
129
+ // Memo key helper for tx parsing
130
+ const beefKey = (beef) => {
131
+ if (typeof beef !== 'object')
132
+ return ''; // The invalid BEEF has an empty key.
133
+ // A fast and deterministic key for memoization; avoids large JSON strings
134
+ // since beef is an array of integers, join is safe and compact.
135
+ return beef.join(',');
136
+ };
137
+ for (const result of hostResponses) {
138
+ if (result.status !== 'fulfilled')
112
139
  continue;
113
- }
114
- try {
115
- for (const output of response.outputs) {
140
+ const response = result.value;
141
+ if (response?.type !== 'output-list' || !Array.isArray(response.outputs))
142
+ continue;
143
+ for (const output of response.outputs) {
144
+ const keyForBeef = beefKey(output.beef);
145
+ let memo = this.txMemo.get(keyForBeef);
146
+ const now = Date.now();
147
+ if (typeof memo !== 'object' || memo === null || memo.expiresAt <= now) {
116
148
  try {
117
- const txId = Transaction.fromBEEF(output.beef).id('hex'); // !! This is STUPIDLY inefficient.
118
- const key = `${txId}.${output.outputIndex}`;
119
- outputs.set(key, output);
149
+ const txId = Transaction.fromBEEF(output.beef).id('hex');
150
+ memo = { txId, expiresAt: now + this.txMemoTtlMs };
151
+ // prune opportunistically if the map gets too large (cheap heuristic)
152
+ if (this.txMemo.size > 4096)
153
+ this.evictOldest(this.txMemo);
154
+ this.txMemo.set(keyForBeef, memo);
120
155
  }
121
156
  catch {
122
157
  continue;
123
158
  }
124
159
  }
125
- }
126
- catch (_) {
127
- // Error processing output, proceed.
160
+ const uniqKey = `${memo.txId}.${output.outputIndex}`;
161
+ // last-writer wins is fine here; outputs are identical if uniqKey matches
162
+ outputsMap.set(uniqKey, output);
128
163
  }
129
164
  }
130
165
  return {
131
166
  type: 'output-list',
132
- outputs: Array.from(outputs.values())
167
+ outputs: Array.from(outputsMap.values())
133
168
  };
134
169
  }
170
+ /**
171
+ * Cached wrapper for competent host discovery with stale-while-revalidate.
172
+ */
173
+ async getCompetentHostsCached(service) {
174
+ const now = Date.now();
175
+ const cached = this.hostsCache.get(service);
176
+ // if fresh, return immediately
177
+ if (typeof cached === 'object' && cached.expiresAt > now) {
178
+ return cached.hosts.slice();
179
+ }
180
+ // if stale but present, kick off a refresh if not already in-flight and return stale
181
+ if (typeof cached === 'object' && cached.expiresAt <= now) {
182
+ if (!this.hostsInFlight.has(service)) {
183
+ this.hostsInFlight.set(service, this.refreshHosts(service).finally(() => {
184
+ this.hostsInFlight.delete(service);
185
+ }));
186
+ }
187
+ return cached.hosts.slice();
188
+ }
189
+ // no cache: coalesce concurrent requests
190
+ if (this.hostsInFlight.has(service)) {
191
+ try {
192
+ const hosts = await this.hostsInFlight.get(service);
193
+ if (typeof hosts !== 'object') {
194
+ throw new Error('Hosts is not defined.');
195
+ }
196
+ return hosts.slice();
197
+ }
198
+ catch {
199
+ // fall through to a fresh attempt below
200
+ }
201
+ }
202
+ const promise = this.refreshHosts(service).finally(() => {
203
+ this.hostsInFlight.delete(service);
204
+ });
205
+ this.hostsInFlight.set(service, promise);
206
+ const hosts = await promise;
207
+ return hosts.slice();
208
+ }
209
+ /**
210
+ * Actually resolves competent hosts from SLAP trackers and updates cache.
211
+ */
212
+ async refreshHosts(service) {
213
+ const hosts = await this.findCompetentHosts(service);
214
+ const expiresAt = Date.now() + this.hostsTtlMs;
215
+ // bounded cache with simple FIFO eviction
216
+ if (!this.hostsCache.has(service) && this.hostsCache.size >= this.hostsMaxEntries) {
217
+ const oldestKey = this.hostsCache.keys().next().value;
218
+ if (oldestKey !== undefined)
219
+ this.hostsCache.delete(oldestKey);
220
+ }
221
+ this.hostsCache.set(service, { hosts, expiresAt });
222
+ return hosts;
223
+ }
135
224
  /**
136
225
  * Returns a list of competent hosts for a given lookup service.
137
226
  * @param service Service for which competent hosts are to be returned
@@ -140,44 +229,42 @@ export default class LookupResolver {
140
229
  async findCompetentHosts(service) {
141
230
  const query = {
142
231
  service: 'ls_slap',
143
- query: {
144
- service
145
- }
232
+ query: { service }
146
233
  };
147
- // Use Promise.allSettled to handle individual SLAP tracker failures
234
+ // Query all SLAP trackers; tolerate failures.
148
235
  const trackerResponses = await Promise.allSettled(this.slapTrackers.map(async (tracker) => await this.facilitator.lookup(tracker, query, MAX_TRACKER_WAIT_TIME)));
149
236
  const hosts = new Set();
150
237
  for (const result of trackerResponses) {
151
- if (result.status === 'fulfilled') {
152
- const answer = result.value;
153
- if (answer.type !== 'output-list') {
154
- // Log invalid response and continue
155
- continue;
156
- }
157
- for (const output of answer.outputs) {
158
- try {
159
- const tx = Transaction.fromBEEF(output.beef);
160
- const script = tx.outputs[output.outputIndex].lockingScript;
161
- const parsed = OverlayAdminTokenTemplate.decode(script);
162
- if (parsed.topicOrService !== service ||
163
- parsed.protocol !== 'SLAP') {
164
- // Invalid advertisement, skip
165
- continue;
166
- }
167
- hosts.add(parsed.domain);
168
- }
169
- catch {
170
- // Invalid output, skip
238
+ if (result.status !== 'fulfilled')
239
+ continue;
240
+ const answer = result.value;
241
+ if (answer.type !== 'output-list')
242
+ continue;
243
+ for (const output of answer.outputs) {
244
+ try {
245
+ const tx = Transaction.fromBEEF(output.beef);
246
+ const script = tx.outputs[output.outputIndex]?.lockingScript;
247
+ if (typeof script !== 'object' || script === null)
171
248
  continue;
249
+ const parsed = OverlayAdminTokenTemplate.decode(script);
250
+ if (parsed.topicOrService !== service || parsed.protocol !== 'SLAP')
251
+ continue;
252
+ if (typeof parsed.domain === 'string' && parsed.domain.length > 0) {
253
+ hosts.add(parsed.domain);
172
254
  }
173
255
  }
174
- }
175
- else {
176
- // Log tracker failure and continue
177
- continue;
256
+ catch {
257
+ continue;
258
+ }
178
259
  }
179
260
  }
180
261
  return [...hosts];
181
262
  }
263
+ /** Evict an arbitrary “oldest” entry from a Map (iteration order). */
264
+ evictOldest(m) {
265
+ const firstKey = m.keys().next().value;
266
+ if (firstKey !== undefined)
267
+ m.delete(firstKey);
268
+ }
182
269
  }
183
270
  //# sourceMappingURL=LookupResolver.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"LookupResolver.js","sourceRoot":"","sources":["../../../../src/overlay-tools/LookupResolver.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAA;AACrD,OAAO,yBAAyB,MAAM,gCAAgC,CAAA;AAgCtE,4BAA4B;AAC5B,MAAM,CAAC,MAAM,qBAAqB,GAAa;IAC7C,gBAAgB;IAChB,gCAAgC;IAChC,gCAAgC;IAChC,gCAAgC;IAEhC,kCAAkC;IAClC,wBAAwB;IAExB,uGAAuG;IACvG,0FAA0F;IAC1F,qEAAqE;IAErE,cAAc;IACd,8GAA8G;CAC/G,CAAA;AA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