corestore init
This commit is contained in:
@@ -201,6 +201,19 @@ async function main() {
|
|||||||
if (cleanStorage) {
|
if (cleanStorage) {
|
||||||
await runPluginStorageReset('--clean startup');
|
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();
|
setupCache();
|
||||||
ca.installRootCA();
|
ca.installRootCA();
|
||||||
|
|
||||||
@@ -287,10 +300,7 @@ async function main() {
|
|||||||
const topic = crypto.createHash('sha256').update(process.env.TOPIC_SEED || 'p2ns-dns').digest();
|
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
|
state.topic = topic; // Store topic in state for keep-alive and cleanup
|
||||||
logDebug('Main', `Generated topic: ${topic.toString('hex')}`);
|
logDebug('Main', `Generated topic: ${topic.toString('hex')}`);
|
||||||
// Initialize corestore and hyperswarm
|
// Corestore is initialized before plugin loading
|
||||||
let store = new Corestore(storageDir);
|
|
||||||
await store.ready();
|
|
||||||
logInfo('Main', `Corestore initialized with storage: ${storageDir}`);
|
|
||||||
// Use the persistent keypair that was loaded earlier (already in state.keypair)
|
// Use the persistent keypair that was loaded earlier (already in state.keypair)
|
||||||
// Configure Hyperswarm for better local network peer discovery
|
// Configure Hyperswarm for better local network peer discovery
|
||||||
const swarmOptions = {
|
const swarmOptions = {
|
||||||
|
|||||||
Reference in New Issue
Block a user