Skip to content
This repository has been archived by the owner on Sep 26, 2019. It is now read-only.

Commit

Permalink
Close Private Storage Provider (#1059)
Browse files Browse the repository at this point in the history
  • Loading branch information
Puneetha17 authored and lucassaldanha committed Mar 10, 2019
1 parent a5fe6b8 commit b7c6834
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ public class PrivacyParameters {
private String publicKey;
private File publicKeyFile;
private WorldStateArchive privateWorldStateArchive;
private StorageProvider privateStorageProvider;

public String getPublicKey() {
return publicKey;
Expand Down Expand Up @@ -91,7 +92,7 @@ public void setPrivacyAddress(final Integer privacyAddress) {

public void enablePrivateDB(final Path path) throws IOException {
final Path privateDbPath = path.resolve(PRIVATE_DATABASE_PATH);
final StorageProvider privateStorageProvider =
this.privateStorageProvider =
RocksDbStorageProvider.create(privateDbPath, new NoOpMetricsSystem());
final WorldStateStorage privateWorldStateStorage =
privateStorageProvider.createWorldStateStorage();
Expand All @@ -101,4 +102,8 @@ public void enablePrivateDB(final Path path) throws IOException {
public WorldStateArchive getPrivateWorldStateArchive() {
return privateWorldStateArchive;
}

public StorageProvider getPrivateStorageProvider() {
return this.privateStorageProvider;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,9 @@ public static PantheonController<Void> init(
}
try {
storageProvider.close();
if (privacyParameters.getPrivateStorageProvider() != null) {
privacyParameters.getPrivateStorageProvider().close();
}
} catch (final IOException e) {
LOG.error("Failed to close storage provider", e);
}
Expand Down

0 comments on commit b7c6834

Please sign in to comment.