Skip to content

Commit

Permalink
fix: only load library if not already loaded
Browse files Browse the repository at this point in the history
Signed-off-by: Timo Glastra <[email protected]>
  • Loading branch information
TimoGlastra committed May 10, 2022
1 parent 7a5b493 commit ac0ea65
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions packages/node/src/PostgresPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ type NativeIndyPostgres = {
init_storagetype: (arg0: string, arg1: string) => number
}

let indyPostgresStorage: NativeIndyPostgres | undefined

export interface WalletStorageConfig {
url: string
wallet_scheme: WalletScheme
Expand All @@ -94,8 +96,10 @@ export interface IndyPostgresStorageConfig {
}

export function loadPostgresPlugin(config: WalletStorageConfig, credentials: WalletStorageCredentials) {
const indyPostgresStorage = getLibrary() as NativeIndyPostgres
if (!indyPostgresStorage) {
indyPostgresStorage = getLibrary()
}

indyPostgresStorage.postgresstorage_init()
indyPostgresStorage.init_storagetype(JSON.stringify(config), JSON.stringify(credentials))
return true
}

0 comments on commit ac0ea65

Please sign in to comment.