@bsv/sdk 1.7.1 → 1.7.2

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.
@@ -31,31 +31,38 @@ export class HTTPSOverlayLookupFacilitator {
31
31
  if (!url.startsWith('https:') && !this.allowHTTP) {
32
32
  throw new Error('HTTPS facilitator can only use URLs that start with "https:"');
33
33
  }
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) {
34
+ const controller = typeof AbortController !== 'undefined' ? new AbortController() : undefined;
35
+ const timer = setTimeout(() => {
36
+ try {
37
+ controller?.abort();
38
+ }
39
+ catch { /* noop */ }
40
+ }, timeout);
41
+ try {
42
+ const fco = {
43
+ method: 'POST',
44
+ headers: { 'Content-Type': 'application/json' },
45
+ body: JSON.stringify({ service: question.service, query: question.query }),
46
+ signal: controller?.signal
47
+ };
48
+ const response = await this.fetchClient(`${url}/lookup`, fco);
49
+ if (!response.ok)
50
+ throw new Error(`Failed to facilitate lookup (HTTP ${response.status})`);
50
51
  return await response.json();
51
52
  }
52
- else {
53
- throw new Error('Failed to facilitate lookup');
53
+ catch (e) {
54
+ // Normalize timeouts to a consistent error message
55
+ if (e?.name === 'AbortError')
56
+ throw new Error('Request timed out');
57
+ throw e;
58
+ }
59
+ finally {
60
+ clearTimeout(timer);
54
61
  }
55
62
  }
56
63
  }
57
64
  /**
58
- * Represents an SHIP transaction broadcaster.
65
+ * Represents a Lookup Resolver.
59
66
  */
60
67
  export default class LookupResolver {
61
68
  facilitator;
@@ -63,12 +70,26 @@ export default class LookupResolver {
63
70
  hostOverrides;
64
71
  additionalHosts;
65
72
  networkPreset;
73
+ // ---- Caches / memoization ----
74
+ hostsCache;
75
+ hostsInFlight;
76
+ hostsTtlMs;
77
+ hostsMaxEntries;
78
+ txMemo;
79
+ txMemoTtlMs;
66
80
  constructor(config = {}) {
67
81
  this.networkPreset = config.networkPreset ?? 'mainnet';
68
82
  this.facilitator = config.facilitator ?? new HTTPSOverlayLookupFacilitator(undefined, this.networkPreset === 'local');
69
83
  this.slapTrackers = config.slapTrackers ?? (this.networkPreset === 'mainnet' ? DEFAULT_SLAP_TRACKERS : DEFAULT_TESTNET_SLAP_TRACKERS);
70
84
  this.hostOverrides = config.hostOverrides ?? {};
71
85
  this.additionalHosts = config.additionalHosts ?? {};
86
+ // cache tuning
87
+ this.hostsTtlMs = config.cache?.hostsTtlMs ?? 5 * 60 * 1000; // 5 min
88
+ this.hostsMaxEntries = config.cache?.hostsMaxEntries ?? 128;
89
+ this.txMemoTtlMs = config.cache?.txMemoTtlMs ?? 10 * 60 * 1000; // 10 min
90
+ this.hostsCache = new Map();
91
+ this.hostsInFlight = new Map();
92
+ this.txMemo = new Map();
72
93
  }
73
94
  /**
74
95
  * Given a LookupQuestion, returns a LookupAnswer. Aggregates across multiple services and supports resiliency.
@@ -85,53 +106,119 @@ export default class LookupResolver {
85
106
  competentHosts = ['http://localhost:8080'];
86
107
  }
87
108
  else {
88
- competentHosts = await this.findCompetentHosts(question.service);
109
+ competentHosts = await this.getCompetentHostsCached(question.service);
89
110
  }
90
111
  if (this.additionalHosts[question.service]?.length > 0) {
91
- competentHosts = [
92
- ...competentHosts,
93
- ...this.additionalHosts[question.service]
94
- ];
112
+ // preserve order: resolved hosts first, then additional (unique)
113
+ const extra = this.additionalHosts[question.service];
114
+ const seen = new Set(competentHosts);
115
+ for (const h of extra)
116
+ if (!seen.has(h))
117
+ competentHosts.push(h);
95
118
  }
96
119
  if (competentHosts.length < 1) {
97
120
  throw new Error(`No competent ${this.networkPreset} hosts found by the SLAP trackers for lookup service: ${question.service}`);
98
121
  }
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') {
122
+ // Fire all hosts with per-host timeout, harvest successful output-list responses
123
+ const hostResponses = await Promise.allSettled(competentHosts.map(async (host) => {
124
+ return await this.facilitator.lookup(host, question, timeout);
125
+ }));
126
+ const outputsMap = new Map();
127
+ // Memo key helper for tx parsing
128
+ const beefKey = (beef) => {
129
+ if (typeof beef !== 'object')
130
+ return ''; // The invalid BEEF has an empty key.
131
+ // A fast and deterministic key for memoization; avoids large JSON strings
132
+ // since beef is an array of integers, join is safe and compact.
133
+ return beef.join(',');
134
+ };
135
+ for (const result of hostResponses) {
136
+ if (result.status !== 'fulfilled')
112
137
  continue;
113
- }
114
- try {
115
- for (const output of response.outputs) {
138
+ const response = result.value;
139
+ if (response?.type !== 'output-list' || !Array.isArray(response.outputs))
140
+ continue;
141
+ for (const output of response.outputs) {
142
+ const keyForBeef = beefKey(output.beef);
143
+ let memo = this.txMemo.get(keyForBeef);
144
+ const now = Date.now();
145
+ if (typeof memo !== 'object' || memo === null || memo.expiresAt <= now) {
116
146
  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);
147
+ const txId = Transaction.fromBEEF(output.beef).id('hex');
148
+ memo = { txId, expiresAt: now + this.txMemoTtlMs };
149
+ // prune opportunistically if the map gets too large (cheap heuristic)
150
+ if (this.txMemo.size > 4096)
151
+ this.evictOldest(this.txMemo);
152
+ this.txMemo.set(keyForBeef, memo);
120
153
  }
121
154
  catch {
122
155
  continue;
123
156
  }
124
157
  }
125
- }
126
- catch (_) {
127
- // Error processing output, proceed.
158
+ const uniqKey = `${memo.txId}.${output.outputIndex}`;
159
+ // last-writer wins is fine here; outputs are identical if uniqKey matches
160
+ outputsMap.set(uniqKey, output);
128
161
  }
129
162
  }
130
163
  return {
131
164
  type: 'output-list',
132
- outputs: Array.from(outputs.values())
165
+ outputs: Array.from(outputsMap.values())
133
166
  };
134
167
  }
168
+ /**
169
+ * Cached wrapper for competent host discovery with stale-while-revalidate.
170
+ */
171
+ async getCompetentHostsCached(service) {
172
+ const now = Date.now();
173
+ const cached = this.hostsCache.get(service);
174
+ // if fresh, return immediately
175
+ if (typeof cached === 'object' && cached.expiresAt > now) {
176
+ return cached.hosts.slice();
177
+ }
178
+ // if stale but present, kick off a refresh if not already in-flight and return stale
179
+ if (typeof cached === 'object' && cached.expiresAt <= now) {
180
+ if (!this.hostsInFlight.has(service)) {
181
+ this.hostsInFlight.set(service, this.refreshHosts(service).finally(() => {
182
+ this.hostsInFlight.delete(service);
183
+ }));
184
+ }
185
+ return cached.hosts.slice();
186
+ }
187
+ // no cache: coalesce concurrent requests
188
+ if (this.hostsInFlight.has(service)) {
189
+ try {
190
+ const hosts = await this.hostsInFlight.get(service);
191
+ if (typeof hosts !== 'object') {
192
+ throw new Error('Hosts is not defined.');
193
+ }
194
+ return hosts.slice();
195
+ }
196
+ catch {
197
+ // fall through to a fresh attempt below
198
+ }
199
+ }
200
+ const promise = this.refreshHosts(service).finally(() => {
201
+ this.hostsInFlight.delete(service);
202
+ });
203
+ this.hostsInFlight.set(service, promise);
204
+ const hosts = await promise;
205
+ return hosts.slice();
206
+ }
207
+ /**
208
+ * Actually resolves competent hosts from SLAP trackers and updates cache.
209
+ */
210
+ async refreshHosts(service) {
211
+ const hosts = await this.findCompetentHosts(service);
212
+ const expiresAt = Date.now() + this.hostsTtlMs;
213
+ // bounded cache with simple FIFO eviction
214
+ if (!this.hostsCache.has(service) && this.hostsCache.size >= this.hostsMaxEntries) {
215
+ const oldestKey = this.hostsCache.keys().next().value;
216
+ if (oldestKey !== undefined)
217
+ this.hostsCache.delete(oldestKey);
218
+ }
219
+ this.hostsCache.set(service, { hosts, expiresAt });
220
+ return hosts;
221
+ }
135
222
  /**
136
223
  * Returns a list of competent hosts for a given lookup service.
137
224
  * @param service Service for which competent hosts are to be returned
@@ -140,44 +227,42 @@ export default class LookupResolver {
140
227
  async findCompetentHosts(service) {
141
228
  const query = {
142
229
  service: 'ls_slap',
143
- query: {
144
- service
145
- }
230
+ query: { service }
146
231
  };
147
- // Use Promise.allSettled to handle individual SLAP tracker failures
232
+ // Query all SLAP trackers; tolerate failures.
148
233
  const trackerResponses = await Promise.allSettled(this.slapTrackers.map(async (tracker) => await this.facilitator.lookup(tracker, query, MAX_TRACKER_WAIT_TIME)));
149
234
  const hosts = new Set();
150
235
  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
236
+ if (result.status !== 'fulfilled')
237
+ continue;
238
+ const answer = result.value;
239
+ if (answer.type !== 'output-list')
240
+ continue;
241
+ for (const output of answer.outputs) {
242
+ try {
243
+ const tx = Transaction.fromBEEF(output.beef);
244
+ const script = tx.outputs[output.outputIndex]?.lockingScript;
245
+ if (typeof script !== 'object' || script === null)
171
246
  continue;
247
+ const parsed = OverlayAdminTokenTemplate.decode(script);
248
+ if (parsed.topicOrService !== service || parsed.protocol !== 'SLAP')
249
+ continue;
250
+ if (typeof parsed.domain === 'string' && parsed.domain.length > 0) {
251
+ hosts.add(parsed.domain);
172
252
  }
173
253
  }
174
- }
175
- else {
176
- // Log tracker failure and continue
177
- continue;
254
+ catch {
255
+ continue;
256
+ }
178
257
  }
179
258
  }
180
259
  return [...hosts];
181
260
  }
261
+ /** Evict an arbitrary “oldest” entry from a Map (iteration order). */
262
+ evictOldest(m) {
263
+ const firstKey = m.keys().next().value;
264
+ if (firstKey !== undefined)
265
+ m.delete(firstKey);
266
+ }
182
267
  }
183
268
  //# 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;AAED,oCAAoC;AACpC,MAAM,CAAC,MAAM,6BAA6B,GAAa;IACrD,0CAA0C;IAC1C,gCAAgC;CACjC,CAAA;AAED,MAAM,qBAAqB,GAAG,IAAI,CAAA;AAqClC,MAAM,OAAO,6BAA6B;IACxC,WAAW,CAAc;IACzB,SAAS,CAAS;IAElB,YAAa,UAAU,GAAG,KAAK,EAAE,YAAqB,KAAK;QACzD,IAAI,CAAC,WAAW,GAAG,UAAU,CAAA;QAC7B,IAAI,CAAC,SAAS,GAAG,SAAS,CAAA;IAC5B,CAAC;IAED,KAAK,CAAC,MAAM,CACV,GAAW,EACX,QAAwB,EACxB,UAAkB,IAAI;QAEtB,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI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M,CAAC,CAAA;qBACzB;oBAAC,MAAM;wBACN,uBAAuB;wBACvB,SAAQ;qBACT;iBACF;aACF;iBAAM;gBACL,mCAAmC;gBACnC,SAAQ;aACT;SACF;QAED,OAAO,CAAC,GAAG,KAAK,CAAC,CAAA;IACnB,CAAC;CACF"}
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;AAED,oCAAoC;AACpC,MAAM,CAAC,MAAM,6BAA6B,GAAa;IACrD,0CAA0C;IAC1C,gCAAgC;CACjC,CAAA;AAED,MAAM,qBAAqB,GAAG,IAAI,CAAA;AAiDlC,MAAM,OAAO,6BAA6B;IACxC,WAAW,CAAc;IACzB,SAAS,CAAS;IAElB,YAAa,UAAU,GAAG,KAAK,EAAE,YAAqB,KAAK;QACzD,IAAI,CAAC,WAAW,GAAG,UAAU,CAAA;QAC7B,IAAI,CAAC,SAAS,GAAG,SAAS,CAAA;IAC5B,CAAC;IAED,KAAK,CAAC,MAAM,CACV,GAAW,EACX,QAAwB,EACxB,UAAkB,IAAI;QAEtB,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE;YAChD,MAAM,IAAI,KAAK,CACb,8DAA8D,CAC/D,CAAA;SACF;QAED,MAAM,UAAU,GAAG,OAAO,eAAe,KAAK,WAAW,CAAC,CAAC,CAAC,IAAI,eAAe,EAAE,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