clearing instances
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2021-01-15 14:45:05 +01:00
parent d286548850
commit a3f021fdd2
6 changed files with 62 additions and 7 deletions

View File

@ -7,7 +7,7 @@
interface Signature {
hash: string;
iat: Date;
iat: number;
}
class Blacklist {
@ -17,15 +17,15 @@ class Blacklist {
this._signatures = [];
}
public clear_before (date: Date):void {
public clear (before: number = Number.POSITIVE_INFINITY):void {
for (let i = this._signatures.length - 1; i >= 0; i--) {
if (this._signatures[i].iat < date)
if (this._signatures[i].iat < before)
this._signatures.splice (i, 1);
}
}
public add_signature (hash: string):void {
this._signatures.push ({ iat: (new Date), hash });
this._signatures.push ({ iat: Date.now (), hash });
}
public remove_signature (hash:string):void {

View File

@ -144,6 +144,11 @@ class KeyStore {
}
this.garbage_collect ();
}
public reset_instance (): void {
this._instance = to_b58 (random_hex (16), 'hex');
this._keys = {};
}
}
const ks: KeyStore = (new KeyStore);