fix(smartacme): Centralize interest map coordination and remove redundant interestMap from cert managers
This commit is contained in:
@ -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);
|
||||
}
|
||||
}
|
@ -6,7 +6,6 @@ import { SmartacmeCert } from '../smartacme.classes.cert.js';
|
||||
* MongoDB-backed certificate manager using EasyStore from smartdata.
|
||||
*/
|
||||
export class MongoCertManager implements ICertManager {
|
||||
public interestMap: plugins.lik.InterestMap<string, SmartacmeCert>;
|
||||
private db: plugins.smartdata.SmartdataDb;
|
||||
private store: plugins.smartdata.EasyStore<Record<string, any>>;
|
||||
|
||||
@ -20,7 +19,6 @@ export class MongoCertManager implements ICertManager {
|
||||
'smartacme-certs',
|
||||
this.db,
|
||||
);
|
||||
this.interestMap = new plugins.lik.InterestMap((domain) => domain);
|
||||
}
|
||||
|
||||
public async init(): Promise<void> {
|
||||
@ -35,11 +33,6 @@ export class MongoCertManager implements ICertManager {
|
||||
public async storeCertificate(cert: SmartacmeCert): Promise<void> {
|
||||
// write plain object for persistence
|
||||
await this.store.writeKey(cert.domainName, { ...cert });
|
||||
const interest = this.interestMap.findInterest(cert.domainName);
|
||||
if (interest) {
|
||||
interest.fullfillInterest(cert);
|
||||
interest.markLost();
|
||||
}
|
||||
}
|
||||
|
||||
public async deleteCertificate(domainName: string): Promise<void> {
|
||||
@ -55,7 +48,5 @@ export class MongoCertManager implements ICertManager {
|
||||
public async wipe(): Promise<void> {
|
||||
// clear all keys in the easy store
|
||||
await this.store.wipe();
|
||||
// reset interest map
|
||||
this.interestMap = new plugins.lik.InterestMap((domain) => domain);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user