Autopass updates

This commit is contained in:
Raven Scott
2026-05-27 19:41:21 -04:00
parent bfc51b8edb
commit 3ece7abe9f
2 changed files with 74 additions and 20 deletions
+26 -15
View File
@@ -51,6 +51,21 @@ const countedResolutions = new Set(); // Set of resolution keys: "domain:claiman
const countedQuorumFailures = new Set(); // Set of domain names that have been counted for quorum failures
const countedTies = new Set(); // Set of tie keys: "domain:claimant"
/**
* Whether dnsPass / Autobase is safe to read or write.
* @param {object|null} pass - Autopass instance
* @returns {boolean}
*/
function isDnsPassUsable(pass) {
if (!pass) return false;
if (pass.closed) return false;
const base = pass.base;
if (!base) return false;
if (base.closed || base.closing) return false;
if (!pass.ready) return false;
return true;
}
async function getAllEntries(pass = state.dnsPass, useCache = true) {
// Skip operations during shutdown to prevent corestore access errors
if (state.isShuttingDown) {
@@ -72,15 +87,8 @@ async function getAllEntries(pass = state.dnsPass, useCache = true) {
return [];
}
// Check if pass is closed
if (pass.closed) {
logDebug('Core', 'dnsPass is closed, returning cached entries');
return entriesCache || [];
}
// Check if pass is ready - if not, wait briefly or return cached entries
if (!pass.ready) {
logDebug('Core', 'dnsPass is not ready yet, returning cached entries');
if (!isDnsPassUsable(pass)) {
logDebug('Core', 'dnsPass is not usable (closed, closing, or not ready), returning cached entries');
return entriesCache || [];
}
@@ -98,7 +106,12 @@ async function getAllEntries(pass = state.dnsPass, useCache = true) {
entriesCacheTimestamp = now;
logDebug('Core', `Cached ${entries.length} entries`);
} catch (err) {
logError('Core', `Error getting entries: ${err.message}`);
const msg = err.message || '';
if (msg.includes('SESSION_CLOSED') || msg.includes('closing core')) {
logWarn('Core', `dnsPass core is closing — stop the node and restart with --clean if this persists after upgrading Autopass: ${msg}`);
} else {
logError('Core', `Error getting entries: ${msg}`);
}
}
return entries;
}
@@ -584,11 +597,8 @@ async function doAutoVotes() {
}
const pass = state.dnsPass;
if (!pass) return;
// Check if pass is closed
if (pass.closed) {
logDebug('Core', 'dnsPass is closed, skipping doAutoVotes');
if (!isDnsPassUsable(pass)) {
logDebug('Core', 'dnsPass is not usable, skipping doAutoVotes');
return;
}
@@ -917,6 +927,7 @@ module.exports = {
getLocalClaimHash,
doAutoVotes,
getAllEntries,
isDnsPassUsable,
autoVoteForDomain,
voteForDomain,
removeDomain,