fix(smartacme): Centralize interest map coordination and remove redundant interestMap from cert managers

This commit is contained in:
2025-05-01 09:28:10 +00:00
parent b8bb4af184
commit c863c7295d
5 changed files with 33 additions and 24 deletions

View File

@ -7,12 +7,8 @@ import { SmartacmeCert } from '../smartacme.classes.cert.js';
* Stores certificates in memory only and does not connect to MongoDB.
*/
export class MemoryCertManager implements ICertManager {
public interestMap: plugins.lik.InterestMap<string, SmartacmeCert>;
private certs: Map<string, SmartacmeCert> = new Map();
constructor() {
this.interestMap = new plugins.lik.InterestMap((domain) => domain);
}
public async init(): Promise<void> {
// no-op for in-memory store
@ -24,11 +20,6 @@ export class MemoryCertManager implements ICertManager {
public async storeCertificate(cert: SmartacmeCert): Promise<void> {
this.certs.set(cert.domainName, cert);
const interest = this.interestMap.findInterest(cert.domainName);
if (interest) {
interest.fullfillInterest(cert);
interest.markLost();
}
}
public async deleteCertificate(domainName: string): Promise<void> {
@ -43,7 +34,5 @@ export class MemoryCertManager implements ICertManager {
*/
public async wipe(): Promise<void> {
this.certs.clear();
// reset interest map
this.interestMap = new plugins.lik.InterestMap((domain) => domain);
}
}