Skip to content

Commit

Permalink
feat: improved performance on pool refresh (#1579)
Browse files Browse the repository at this point in the history
Signed-off-by: wadeking98 <[email protected]>
  • Loading branch information
wadeking98 authored Oct 31, 2023
1 parent 71a525e commit 3070120
Show file tree
Hide file tree
Showing 4 changed files with 86 additions and 2 deletions.
68 changes: 68 additions & 0 deletions .yarn/patches/@aries-framework-indy-vdr-npm-0.4.0-b01067562c.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
diff --git a/build/index.d.ts b/build/index.d.ts
index 880dd84215c90d7556ebca5c53f7a73050136c39..3e43fa5f05d16405e1ad6e73a66bbbe89c703b11 100644
--- a/build/index.d.ts
+++ b/build/index.d.ts
@@ -1,5 +1,5 @@
export { IndyVdrIndyDidRegistrar, IndyVdrIndyDidResolver, IndyVdrSovDidResolver, IndyVdrDidCreateResult, IndyVdrDidCreateOptions, } from './dids';
-export { IndyVdrPoolConfig } from './pool';
+export { IndyVdrPoolConfig, IndyVdrPoolService } from './pool';
export * from './IndyVdrModule';
export * from './IndyVdrModuleConfig';
export * from './anoncreds';
diff --git a/build/pool/IndyVdrPool.d.ts b/build/pool/IndyVdrPool.d.ts
index cff86a7a020c7c6152a7c08f4ce0cb4e83b3838d..ff439c23140b5a8e9d27595ecf5f813cbca7a7a1 100644
--- a/build/pool/IndyVdrPool.d.ts
+++ b/build/pool/IndyVdrPool.d.ts
@@ -31,6 +31,7 @@ export declare class IndyVdrPool {
get indyNamespace(): string;
get config(): IndyVdrPoolConfig;
connect(): void;
+ public refreshConnection(): Promise<void>;
private get pool();
close(): void;
prepareWriteRequest<Request extends IndyVdrRequest>(agentContext: AgentContext, request: Request, signingKey: Key, endorserDid?: string): Promise<Request>;
diff --git a/build/pool/IndyVdrPool.js b/build/pool/IndyVdrPool.js
index 0ec57415429a0b97844b2d65a8ee83f68ad10466..56dc4c3702a0a540fda7cf1f97c2233fc5f7546c 100644
--- a/build/pool/IndyVdrPool.js
+++ b/build/pool/IndyVdrPool.js
@@ -25,6 +25,11 @@ class IndyVdrPool {
},
});
}
+ async refreshConnection() {
+ if (this._pool) {
+ await this.pool.refresh()
+ }
+ }
get pool() {
if (!this._pool)
this.connect();
diff --git a/build/pool/IndyVdrPoolService.d.ts b/build/pool/IndyVdrPoolService.d.ts
index a21dca227076c7097bea4409233bf547eb229f11..432a2dd842076776b90b0cce08e658054fd677fe 100644
--- a/build/pool/IndyVdrPoolService.d.ts
+++ b/build/pool/IndyVdrPoolService.d.ts
@@ -31,6 +31,7 @@ export declare class IndyVdrPoolService {
}>;
private getPoolForLegacyDid;
private getSettledDidResponsesFromPools;
+ public refreshPoolConnections(): Promise<PromiseSettledResult<void>[]>;
/**
* Get the most appropriate pool for the given indyNamespace
*/
diff --git a/build/pool/IndyVdrPoolService.js b/build/pool/IndyVdrPoolService.js
index e5abc0d40cae5a4d5777220fd0c36d85496df313..3c581926d0bd31b595e498815b730263cdd5e6ef 100644
--- a/build/pool/IndyVdrPoolService.js
+++ b/build/pool/IndyVdrPoolService.js
@@ -113,6 +113,12 @@ let IndyVdrPoolService = class IndyVdrPoolService {
successful,
};
}
+ /**
+ * Refresh the pool connections asynchronously
+ */
+ refreshPoolConnections() {
+ return Promise.allSettled(this.pools.map((pool) => pool.refreshConnection()))
+ }
/**
* Get the most appropriate pool for the given indyNamespace
*/
3 changes: 3 additions & 0 deletions app/src/screens/Splash.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
MediatorPickupStrategy,
WsOutboundTransport,
} from '@aries-framework/core'
import { IndyVdrPoolService } from '@aries-framework/indy-vdr/build/pool'
import { useAgent } from '@aries-framework/react-hooks'
import { agentDependencies } from '@aries-framework/react-native'
import AsyncStorage from '@react-native-async-storage/async-storage'
Expand Down Expand Up @@ -395,6 +396,8 @@ const Splash: React.FC = () => {

setStep(6)
await newAgent.initialize()
const poolService = newAgent.dependencyManager.resolve(IndyVdrPoolService)
await poolService.refreshPoolConnections()

setStep(7)
await createLinkSecretIfRequired(newAgent)
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
"@aries-framework/react-hooks@^0.4.2": "patch:@aries-framework/react-hooks@npm:0.4.2#./.yarn/patches/@aries-framework-react-hooks-npm-0.4.2-84b7eb8764.patch",
"@aries-framework/[email protected]": "patch:@aries-framework/react-native@npm:0.3.3#./.yarn/patches/@aries-framework-react-native-npm-0.3.3-bb75ece22d.patch",
"@aries-framework/anoncreds@^0.4.0": "patch:@aries-framework/anoncreds@npm%3A0.4.0#./.yarn/patches/@aries-framework-anoncreds-npm-0.4.0-4d3b4e769d.patch",
"@aries-framework/[email protected]": "patch:@aries-framework/anoncreds@npm%3A0.4.0#./.yarn/patches/@aries-framework-anoncreds-npm-0.4.0-4d3b4e769d.patch"
"@aries-framework/[email protected]": "patch:@aries-framework/anoncreds@npm%3A0.4.0#./.yarn/patches/@aries-framework-anoncreds-npm-0.4.0-4d3b4e769d.patch",
"@aries-framework/indy-vdr@^0.4.0": "patch:@aries-framework/indy-vdr@npm%3A0.4.0#./.yarn/patches/@aries-framework-indy-vdr-npm-0.4.0-b01067562c.patch"
}
}
14 changes: 13 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ __metadata:
languageName: node
linkType: hard

"@aries-framework/indy-vdr@npm:^0.4.0":
"@aries-framework/indy-vdr@npm:0.4.0":
version: 0.4.0
resolution: "@aries-framework/indy-vdr@npm:0.4.0"
dependencies:
Expand All @@ -141,6 +141,18 @@ __metadata:
languageName: node
linkType: hard

"@aries-framework/indy-vdr@patch:@aries-framework/indy-vdr@npm%3A0.4.0#./.yarn/patches/@aries-framework-indy-vdr-npm-0.4.0-b01067562c.patch::locator=bc-wallet-mobile%40workspace%3A.":
version: 0.4.0
resolution: "@aries-framework/indy-vdr@patch:@aries-framework/indy-vdr@npm%3A0.4.0#./.yarn/patches/@aries-framework-indy-vdr-npm-0.4.0-b01067562c.patch::version=0.4.0&hash=0e7997&locator=bc-wallet-mobile%40workspace%3A."
dependencies:
"@aries-framework/anoncreds": 0.4.0
"@aries-framework/core": 0.4.0
peerDependencies:
"@hyperledger/indy-vdr-shared": ^0.1.0
checksum: 71e94580f35810cb603a11af79eef2d8f49a3f8ed2c1b74ff4a66acf2e6db9f9637ac2a3d9f3ed688c73552a69f60e15cc55227c3c949aa481832940589543fa
languageName: node
linkType: hard

"@aries-framework/node@npm:0.4.0":
version: 0.4.0
resolution: "@aries-framework/node@npm:0.4.0"
Expand Down

0 comments on commit 3070120

Please sign in to comment.