Skip to content

Commit f17886c

Browse files
authored
feat: uses expirable map for subnet keys (#796)
1 parent 5b36459 commit f17886c

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

docs/generated/changelog.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ <h1>Agent-JS Changelog</h1>
1212
<section>
1313
<h2>Version x.x.x</h2>
1414
<ul>
15+
<li>feat: uses expirable map for subnet keys in agent-js, with a timeout of 1 hour</li>
1516
<li>chore: cleanup for node 20 development in agent-js</li>
1617
<li>fix: canisterStatus returns full list of controllers</li>
1718
<ul>

packages/agent/src/agent/http/index.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import { AgentHTTPResponseError } from './errors';
3030
import { SubnetStatus, request } from '../../canisterStatus';
3131
import { CertificateVerificationError } from '../../certificate';
3232
import { ed25519 } from '@noble/curves/ed25519';
33+
import { ExpirableMap } from '../../utils/expirableMap';
3334
import { Ed25519PublicKey } from '../../public_key';
3435

3536
export * from './transforms';
@@ -186,7 +187,9 @@ export class HttpAgent implements Agent {
186187
#queryPipeline: HttpAgentRequestTransformFn[] = [];
187188
#updatePipeline: HttpAgentRequestTransformFn[] = [];
188189

189-
#subnetKeys: Map<string, SubnetStatus> = new Map();
190+
#subnetKeys: ExpirableMap<string, SubnetStatus> = new ExpirableMap({
191+
expirationTime: 60 * 60 * 1000, // 1 hour
192+
});
190193
#verifyQuerySignatures = true;
191194

192195
constructor(options: HttpAgentOptions = {}) {

0 commit comments

Comments
 (0)