@@ -220,12 +220,9 @@ async function main() {
|
||||
const topic = crypto.createHash('sha256').update(process.env.TOPIC_SEED || 'p2ns-dns').digest();
|
||||
state.topic = topic; // Store topic in state for keep-alive and cleanup
|
||||
logDebug('Main', `Generated topic: ${topic.toString('hex')}`);
|
||||
|
||||
// Initialize corestore with a stable primaryKey derived from our persistent keypair
|
||||
// This ensures core keys are deterministic and persistent across restarts
|
||||
const primaryKey = crypto.createHash('sha256').update(keypair.secretKey).digest();
|
||||
const store = new Corestore(process.env.STORAGE_DIR || './my-storage', { primaryKey });
|
||||
logInfo('Main', `Corestore initialized with stable primaryKey and storage: ${process.env.STORAGE_DIR || 'my-storage'}`);
|
||||
// Initialize corestore and hyperswarm
|
||||
const store = new Corestore(process.env.STORAGE_DIR || './my-storage');
|
||||
logInfo('Main', `Corestore initialized with storage: ${process.env.STORAGE_DIR || 'my-storage'}`);
|
||||
// Use the persistent keypair that was loaded earlier (already in state.keypair)
|
||||
// Configure Hyperswarm for better local network peer discovery
|
||||
const swarmOptions = {
|
||||
@@ -970,12 +967,7 @@ async function main() {
|
||||
logInfo('Main', 'Autopass ready');
|
||||
state.dnsPass = dnsPass;
|
||||
core = dnsPass.base;
|
||||
|
||||
// Ensure the core is fully ready and updated from disk
|
||||
await core.ready();
|
||||
await core.update();
|
||||
|
||||
logInfo('Main', `Core retrieved. Writable: ${core.writable}, Key: ${core.key.toString('hex')}`);
|
||||
logInfo('Main', `Core retrieved. Writable: ${core.writable}`);
|
||||
// Setup domains watcher for master
|
||||
setupDomainsWatcher();
|
||||
setupListeners();
|
||||
|
||||
@@ -711,11 +711,9 @@ async function setupP2NS() {
|
||||
state.keypair = keypair;
|
||||
logInfo('Main', 'Persistent keypair loaded');
|
||||
|
||||
// Initialize corestore with a stable primaryKey derived from our persistent keypair
|
||||
const primaryKey = crypto.createHash('sha256').update(keypair.secretKey).digest();
|
||||
const store = new Corestore(config.STORAGE_DIR, { primaryKey });
|
||||
const store = new Corestore(config.STORAGE_DIR);
|
||||
state.store = store;
|
||||
logInfo('Main', `Corestore initialized with stable primaryKey`, { storageDir: config.STORAGE_DIR });
|
||||
logInfo('Main', `Corestore initialized`, { storageDir: config.STORAGE_DIR });
|
||||
|
||||
// Use the persistent keypair from state
|
||||
// Configure Hyperswarm for better local network peer discovery
|
||||
|
||||
Reference in New Issue
Block a user