Skip to content

Commit

Permalink
Merge pull request #10 from decentralized-identity/open-parallel
Browse files Browse the repository at this point in the history
Support opening pools in parallel
  • Loading branch information
peacekeeper authored Jan 3, 2024
2 parents f040793 + 4669b60 commit 4a530be
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 2 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@ The driver recognizes the following environment variables:
* Specifies the path to the Indy SDK library.
* Default value: (empty string)

### `uniresolver_driver_did_sov_openParallel`

* Specifies whether to open Indy pools in parallel threads. This speeds up startup, but may consume more memory.
* Default value: false

### `uniresolver_driver_did_sov_poolConfigs`

* Specifies a semi-colon-separated list of Indy network names and pool configuration files. The default network is `_`.
Expand Down
1 change: 1 addition & 0 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ USER jetty
# variables

ENV uniresolver_driver_did_sov_libIndyPath=
ENV uniresolver_driver_did_sov_openParallel=false
ENV uniresolver_driver_did_sov_poolConfigs=_;./sovrin/_.txn;test;./sovrin/test.txn;builder;./sovrin/builder.txn;danube;./sovrin/danube.txn;idunion;./sovrin/idunion.txn;idunion:test;./sovrin/idunion-test.txn;indicio;./sovrin/indicio.txn;indicio:test;./sovrin/indicio-test.txn;indicio:demo;./sovrin/indicio-demo.txn;nxd;./sovrin/nxd.txn;findy:test;./sovrin/findy-test.txn;bcovrin;./sovrin/bcovrin.txn;bcovrin:test;./sovrin/bcovrin-test.txn;bcovrin:dev;./sovrin/bcovrin-dev.txn;candy;./sovrin/candy.txn;candy:test;./sovrin/candy-test.txn;candy:dev;./sovrin/candy-dev.txn
ENV uniresolver_driver_did_sov_poolVersions=_;2;test;2;builder;2;danube;2;idunion;2;idunion:test;2;indicio;2;indicio:test;2;indicio:demo;2;nxd;2;findy:test;2;bcovrin;2;bcovrin:test;2;bcovrin:dev;2;candy;2;candy:test;2;candy:dev;2
ENV uniresolver_driver_did_sov_walletNames=_;w1;test;w2;builder;w3;danube;w4;idunion;w5;idunion:test;w6;indicio;w7;indicio:test;w8;indicio:demo;w9;nxd;w11;findy:test;w12;bcovrin;w13;bcovrin:test;w14;bcovrin:dev;w15;candy;w16;candy:test;w17;candy:dev;w18
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@

<!-- Dependency Versions -->

<libindy-common-java.version>0.3.0</libindy-common-java.version>
<libindy-common-java.version>0.4.0</libindy-common-java.version>
<did-common-java.version>1.11.0</did-common-java.version>

<io.leonard-base58.version>0.0.2</io.leonard-base58.version>
Expand Down
16 changes: 15 additions & 1 deletion src/main/java/uniresolver/driver/did/sov/DidSovDriver.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ public class DidSovDriver implements Driver {
private Map<String, Object> properties;

private LibIndyInitializer libIndyInitializer;
private boolean openParallel;
private IndyConnector indyConnector;

public DidSovDriver(Map<String, Object> properties) {
Expand All @@ -54,12 +55,14 @@ private static Map<String, Object> getPropertiesFromEnvironment() {
try {

String env_libIndyPath = System.getenv("uniresolver_driver_did_sov_libIndyPath");
String env_openParallel = System.getenv("uniresolver_driver_did_sov_openParallel");
String env_poolConfigs = System.getenv("uniresolver_driver_did_sov_poolConfigs");
String env_poolVersions = System.getenv("uniresolver_driver_did_sov_poolVersions");
String env_walletNames = System.getenv("uniresolver_driver_did_sov_walletNames");
String env_submitterDidSeeds = System.getenv("uniresolver_driver_did_sov_submitterDidSeeds");

if (env_libIndyPath != null) properties.put("libIndyPath", env_libIndyPath);
if (env_openParallel != null) properties.put("openParallel", env_openParallel);
if (env_poolConfigs != null) properties.put("poolConfigs", env_poolConfigs);
if (env_poolVersions != null) properties.put("poolVersions", env_poolVersions);
if (env_walletNames != null) properties.put("walletNames", env_walletNames);
Expand All @@ -79,10 +82,13 @@ private void configureFromProperties() {
try {

String prop_libIndyPath = (String) this.getProperties().get("libIndyPath");
String prop_openParallel = (String) this.getProperties().get("openParallel");

this.setLibIndyInitializer(new LibIndyInitializer(
prop_libIndyPath));

this.setOpenParallel(Boolean.parseBoolean(prop_openParallel));

String prop_poolConfigs = (String) this.getProperties().get("poolConfigs");
String prop_poolVersions = (String) this.getProperties().get("poolVersions");
String prop_walletNames = (String) this.getProperties().get("walletNames");
Expand Down Expand Up @@ -114,7 +120,7 @@ public ResolveDataModelResult resolve(DID did, Map<String, Object> resolveOption

if (! this.getIndyConnector().isOpened()) {
try {
this.getIndyConnector().openIndyConnections(true, false);
this.getIndyConnector().openIndyConnections(true, false, this.getOpenParallel());
if (log.isInfoEnabled()) log.info("Successfully opened Indy connections.");
} catch (IndyConnectionException ex) {
throw new ResolutionException("Cannot open Indy connections: " + ex.getMessage(), ex);
Expand Down Expand Up @@ -255,6 +261,14 @@ public void setLibIndyInitializer(LibIndyInitializer libIndyInitializer) {
this.libIndyInitializer = libIndyInitializer;
}

public boolean getOpenParallel() {
return openParallel;
}

public void setOpenParallel(boolean openParallel) {
this.openParallel = openParallel;
}

public IndyConnector getIndyConnector() {
return indyConnector;
}
Expand Down

0 comments on commit 4a530be

Please sign in to comment.