@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.
- package/dist/cjs/package.json +1 -1
- package/dist/cjs/src/overlay-tools/LookupResolver.js +153 -75
- package/dist/cjs/src/overlay-tools/LookupResolver.js.map +1 -1
- package/dist/cjs/tsconfig.cjs.tsbuildinfo +1 -1
- package/dist/esm/src/overlay-tools/LookupResolver.js +160 -75
- package/dist/esm/src/overlay-tools/LookupResolver.js.map +1 -1
- package/dist/esm/tsconfig.esm.tsbuildinfo +1 -1
- package/dist/types/src/overlay-tools/LookupResolver.d.ts +29 -1
- package/dist/types/src/overlay-tools/LookupResolver.d.ts.map +1 -1
- package/dist/types/tsconfig.types.tsbuildinfo +1 -1
- package/dist/umd/bundle.js +3 -3
- package/dist/umd/bundle.js.map +1 -1
- package/docs/reference/overlay-tools.md +10 -1
- package/package.json +1 -1
- package/src/overlay-tools/LookupResolver.ts +168 -81
- package/src/overlay-tools/__tests/LookupResolver.test.ts +0 -47
|
@@ -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
|
|
35
|
-
const
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
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
|
-
|
|
53
|
-
|
|
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
|
|
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.
|
|
109
|
+
competentHosts = await this.getCompetentHostsCached(question.service);
|
|
89
110
|
}
|
|
90
111
|
if (this.additionalHosts[question.service]?.length > 0) {
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
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
|
-
//
|
|
100
|
-
const hostResponses = await Promise.allSettled(competentHosts.map(async (host) =>
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
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
|
-
|
|
115
|
-
|
|
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');
|
|
118
|
-
|
|
119
|
-
|
|
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
|
-
|
|
127
|
-
|
|
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(
|
|
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
|
-
//
|
|
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
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
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
|
-
|
|
176
|
-
|
|
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;
|
|
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,Q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