removes duplicate keys which cause keychecker to get stuck
This commit is contained in:
parent
673f6f6185
commit
5c885eaa1a
|
@ -101,12 +101,6 @@ export class KeyChecker {
|
||||||
// for the next check.
|
// for the next check.
|
||||||
if (key.isDisabled) {
|
if (key.isDisabled) {
|
||||||
this.log.warn({ key: key.hash }, "Skipping check for disabled key.");
|
this.log.warn({ key: key.hash }, "Skipping check for disabled key.");
|
||||||
// If this is a startup check (key was disabled while we were waiting for
|
|
||||||
// the initial check), we need to set its lastChecked, otherwise we'll
|
|
||||||
// get stuck in a loop.
|
|
||||||
if (!key.lastChecked) {
|
|
||||||
this.updateKey(key.hash, {});
|
|
||||||
}
|
|
||||||
this.scheduleNextCheck();
|
this.scheduleNextCheck();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -69,6 +69,7 @@ export class KeyPool {
|
||||||
}
|
}
|
||||||
let bareKeys: string[];
|
let bareKeys: string[];
|
||||||
bareKeys = keyString.split(",").map((k) => k.trim());
|
bareKeys = keyString.split(",").map((k) => k.trim());
|
||||||
|
bareKeys = [...new Set(bareKeys)];
|
||||||
for (const k of bareKeys) {
|
for (const k of bareKeys) {
|
||||||
const newKey = {
|
const newKey = {
|
||||||
key: k,
|
key: k,
|
||||||
|
@ -82,7 +83,7 @@ export class KeyPool {
|
||||||
lastUsed: 0,
|
lastUsed: 0,
|
||||||
lastChecked: 0,
|
lastChecked: 0,
|
||||||
promptCount: 0,
|
promptCount: 0,
|
||||||
hash: crypto.createHash("sha256").update(k).digest("hex").slice(0, 6),
|
hash: crypto.createHash("sha256").update(k).digest("hex").slice(0, 8),
|
||||||
};
|
};
|
||||||
this.keys.push(newKey);
|
this.keys.push(newKey);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue