From b32c2327e9dd364df92373c3ae4498556d994f91 Mon Sep 17 00:00:00 2001 From: Alessio Treglia Date: Sat, 20 Oct 2018 22:51:02 -0700 Subject: [PATCH] Add CloseDB() call --- PENDING.md | 1 + crypto/keys/keybase.go | 5 +++++ crypto/keys/types.go | 3 +++ 3 files changed, 9 insertions(+) diff --git a/PENDING.md b/PENDING.md index 4df858312829..44053a1a0cd9 100644 --- a/PENDING.md +++ b/PENDING.md @@ -146,6 +146,7 @@ FEATURES basis for the validator commission model. * [x/auth] Support account removal in the account mapper. * [client/keys] [\#2544](https://github.com/cosmos/cosmos-sdk/issues/2544) Add `GetReadOnlyKeyBase()` to acquire read-only LevelDB databases. + * [crypto/keys] [\#2544](https://github.com/cosmos/cosmos-sdk/issues/2544) Add `CloseDB()` to release locks and close the storage backend. * Tendermint diff --git a/crypto/keys/keybase.go b/crypto/keys/keybase.go index ddcd0357e1a3..b75c3473ba81 100644 --- a/crypto/keys/keybase.go +++ b/crypto/keys/keybase.go @@ -426,6 +426,11 @@ func (kb dbKeybase) Update(name, oldpass string, getNewpass func() (string, erro } } +// CloseDB releases the lock and closes the storage backend. +func (kb dbKeybase) CloseDB() { + kb.db.Close() +} + func (kb dbKeybase) writeLocalKey(priv tmcrypto.PrivKey, name, passphrase string) Info { // encrypt private key using passphrase privArmor := mintkey.EncryptArmorPrivKey(priv, passphrase) diff --git a/crypto/keys/types.go b/crypto/keys/types.go index f5194748a01f..77d78958f77e 100644 --- a/crypto/keys/types.go +++ b/crypto/keys/types.go @@ -47,6 +47,9 @@ type Keybase interface { // *only* works on locally-stored keys. Temporary method until we redo the exporting API ExportPrivateKeyObject(name string, passphrase string) (crypto.PrivKey, error) + + // Close the database + CloseDB() } // KeyType reflects a human-readable type for key listing.