corestore init
This commit is contained in:
@@ -201,6 +201,19 @@ async function main() {
|
||||
if (cleanStorage) {
|
||||
await runPluginStorageReset('--clean startup');
|
||||
}
|
||||
|
||||
// Initialize the main Corestore before plugins so storage is guaranteed to exist
|
||||
// even if a plugin fails during startup.
|
||||
let store = null;
|
||||
try {
|
||||
store = new Corestore(storageDir);
|
||||
await store.ready();
|
||||
logInfo('Main', `Corestore initialized with storage: ${storageDir}`);
|
||||
} catch (err) {
|
||||
logError('Main', `Failed to initialize corestore at ${storageDir}: ${err.message}`);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
setupCache();
|
||||
ca.installRootCA();
|
||||
|
||||
@@ -287,10 +300,7 @@ 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 and hyperswarm
|
||||
let store = new Corestore(storageDir);
|
||||
await store.ready();
|
||||
logInfo('Main', `Corestore initialized with storage: ${storageDir}`);
|
||||
// Corestore is initialized before plugin loading
|
||||
// Use the persistent keypair that was loaded earlier (already in state.keypair)
|
||||
// Configure Hyperswarm for better local network peer discovery
|
||||
const swarmOptions = {
|
||||
|
||||
Reference in New Issue
Block a user