Skip to content

Commit

Permalink
Fix Holochain initialization on unlock
Browse files Browse the repository at this point in the history
  • Loading branch information
lucksus committed Mar 21, 2024
1 parent fbd5662 commit ef25e90
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 17 deletions.
5 changes: 1 addition & 4 deletions executor/src/core/Ad4mCore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,10 +114,7 @@ export default class Ad4mCore {
}
}

get holochainService(): HolochainService {
if (!this.#holochain) {
throw Error("No holochain service")
}
get holochainService(): HolochainService | undefined {
return this.#holochain
}

Expand Down
24 changes: 11 additions & 13 deletions executor/src/core/graphQL-interface/GraphQL.ts
Original file line number Diff line number Diff line change
Expand Up @@ -381,22 +381,20 @@ export function createResolvers(core: Ad4mCore, config: OuterConfig) {
}

if(core.agentService.isUnlocked()) {
try {
await core.waitForAgent();
core.initControllers()
await core.initLanguages();
} catch (e) {
if(!core.holochainService) {
console.log("Holochain service not initialized. Initializing...")
// @ts-ignore
const {hcPortAdmin, connectHolochain, hcPortApp, hcUseLocalProxy, hcUseMdns, hcUseProxy, hcUseBootstrap, hcProxyUrl, hcBootstrapUrl} = config;
//if (args.holochain === "true") {
await core.initHolochain({ hcPortAdmin, hcPortApp, hcUseLocalProxy, hcUseMdns, hcUseProxy, hcUseBootstrap, passphrase: args.passphrase, hcProxyUrl, hcBootstrapUrl });
//}
await core.waitForAgent();
core.initControllers()
await core.initLanguages()

console.log("\x1b[32m", "AD4M init complete", "\x1b[0m");
await core.initHolochain({ hcPortAdmin, hcPortApp, hcUseLocalProxy, hcUseMdns, hcUseProxy, hcUseBootstrap, passphrase: args.passphrase, hcProxyUrl, hcBootstrapUrl });
} else {
console.log("Holo service already initialized")
}

await core.waitForAgent();
core.initControllers()
await core.initLanguages()

console.log("\x1b[32m", "AD4M init complete", "\x1b[0m");

try {
await core.agentService.ensureAgentExpression();
Expand Down

0 comments on commit ef25e90

Please sign in to comment.