From 5e0f280caf39458485635339c08ce916149490a3 Mon Sep 17 00:00:00 2001 From: Chris Elder Date: Tue, 18 Apr 2017 09:26:11 -0400 Subject: [PATCH] [FAB-3185] move historyDatabase to ledger in core.yaml historyDatabase is under 'state' section in core.yaml. 'history' should be a peer of 'state', with the config option being called something like enableHistoryDatabase. This will allow for other history config options distinct from state config options. This is the default core.yaml with the new history section and enableHistoryDatabase config option: ledger: blockchain: state: # stateDatabase - options are "goleveldb", "CouchDB" # goleveldb - default state database stored in goleveldb. # CouchDB - store state database in CouchDB stateDatabase: goleveldb couchDBConfig: couchDBAddress: 127.0.0.1:5984 username: password: # Number of retries for CouchDB errors maxRetries: 3 # Number of retries for CouchDB errors during peer startup maxRetriesOnStartup: 10 # CouchDB request timeout (unit: duration, e.g. 20s) requestTimeout: 20s # Limit on the number of records to return per query queryLimit: 10000 history: # enableHistoryDatabase - options are true or false # Indicates if the history of key updates should be stored in goleveldb enableHistoryDatabase: true The history section in chaincodetest.yaml is not used, update it for consistency. Change-Id: I15ac35e280dbf194647ca0c866fcbee515af8a68 Signed-off-by: Chris Elder --- core/chaincode/chaincodetest.yaml | 10 +++++----- .../historydb/historyleveldb/historyleveldb_test.go | 2 +- .../history/historydb/historyleveldb/pkg_test.go | 2 +- core/ledger/ledgerconfig/ledger_config.go | 2 +- core/ledger/ledgerconfig/ledger_config_test.go | 4 ++-- core/ledger/testutil/test_util.go | 2 +- peer/core.yaml | 9 +++++---- 7 files changed, 16 insertions(+), 15 deletions(-) diff --git a/core/chaincode/chaincodetest.yaml b/core/chaincode/chaincodetest.yaml index ac688e7df57..89a6931a5ed 100644 --- a/core/chaincode/chaincodetest.yaml +++ b/core/chaincode/chaincodetest.yaml @@ -435,14 +435,14 @@ ledger: # CouchDB request timeout (unit: duration, e.g. 20s) requestTimeout: 20s - - # historyDatabase - options are true or false - # Indicates if the history of key updates should be stored in goleveldb - historyDatabase: true - # Limit on the number of records to return per query queryLimit: 10000 + history: + # enableHistoryDatabase - options are true or false + # Indicates if the history of key updates should be stored in goleveldb + enableHistoryDatabase: true + ################################################################################ # diff --git a/core/ledger/kvledger/history/historydb/historyleveldb/historyleveldb_test.go b/core/ledger/kvledger/history/historydb/historyleveldb/historyleveldb_test.go index f46573f43bf..77bf8409c06 100644 --- a/core/ledger/kvledger/history/historydb/historyleveldb/historyleveldb_test.go +++ b/core/ledger/kvledger/history/historydb/historyleveldb/historyleveldb_test.go @@ -195,7 +195,7 @@ func TestHistoryDisabled(t *testing.T) { env := NewTestHistoryEnv(t) defer env.cleanup() - viper.Set("ledger.state.historyDatabase", "false") + viper.Set("ledger.history.enableHistoryDatabase", "false") //no need to pass blockstore into history executore, it won't be used in this test qhistory, err := env.testHistoryDB.NewHistoryQueryExecutor(nil) diff --git a/core/ledger/kvledger/history/historydb/historyleveldb/pkg_test.go b/core/ledger/kvledger/history/historydb/historyleveldb/pkg_test.go index d04c4ef0f78..1068c82c076 100644 --- a/core/ledger/kvledger/history/historydb/historyleveldb/pkg_test.go +++ b/core/ledger/kvledger/history/historydb/historyleveldb/pkg_test.go @@ -45,7 +45,7 @@ type levelDBLockBasedHistoryEnv struct { func NewTestHistoryEnv(t *testing.T) *levelDBLockBasedHistoryEnv { - viper.Set("ledger.state.historyDatabase", "true") + viper.Set("ledger.history.enableHistoryDatabase", "true") blockStorageTestEnv := newBlockStorageTestEnv(t) diff --git a/core/ledger/ledgerconfig/ledger_config.go b/core/ledger/ledgerconfig/ledger_config.go index 378c4a55560..a9ff636be94 100644 --- a/core/ledger/ledgerconfig/ledger_config.go +++ b/core/ledger/ledgerconfig/ledger_config.go @@ -99,7 +99,7 @@ func GetQueryLimit() int { //IsHistoryDBEnabled exposes the historyDatabase variable func IsHistoryDBEnabled() bool { - return viper.GetBool("ledger.state.historyDatabase") + return viper.GetBool("ledger.history.enableHistoryDatabase") } // IsQueryReadsHashingEnabled enables or disables computing of hash diff --git a/core/ledger/ledgerconfig/ledger_config_test.go b/core/ledger/ledgerconfig/ledger_config_test.go index bb866766845..3efd0c640d9 100644 --- a/core/ledger/ledgerconfig/ledger_config_test.go +++ b/core/ledger/ledgerconfig/ledger_config_test.go @@ -69,7 +69,7 @@ func TestIsHistoryDBEnabledDefault(t *testing.T) { func TestIsHistoryDBEnabledTrue(t *testing.T) { setUpCoreYAMLConfig() defer ledgertestutil.ResetConfigToDefaultValues() - viper.Set("ledger.state.historyDatabase", true) + viper.Set("ledger.history.enableHistoryDatabase", true) updatedValue := IsHistoryDBEnabled() testutil.AssertEquals(t, updatedValue, true) //test config returns true } @@ -77,7 +77,7 @@ func TestIsHistoryDBEnabledTrue(t *testing.T) { func TestIsHistoryDBEnabledFalse(t *testing.T) { setUpCoreYAMLConfig() defer ledgertestutil.ResetConfigToDefaultValues() - viper.Set("ledger.state.historyDatabase", false) + viper.Set("ledger.history.enableHistoryDatabase", false) updatedValue := IsHistoryDBEnabled() testutil.AssertEquals(t, updatedValue, false) //test config returns false } diff --git a/core/ledger/testutil/test_util.go b/core/ledger/testutil/test_util.go index 145209c9521..aba2180ff06 100644 --- a/core/ledger/testutil/test_util.go +++ b/core/ledger/testutil/test_util.go @@ -84,7 +84,7 @@ func SetupCoreYAMLConfig(coreYamlPath string) { func ResetConfigToDefaultValues() { //reset to defaults viper.Set("ledger.state.stateDatabase", "goleveldb") - viper.Set("ledger.state.historyDatabase", false) + viper.Set("ledger.history.enableHistoryDatabase", false) } // SetLogLevel sets up log level diff --git a/peer/core.yaml b/peer/core.yaml index 40ceb288b81..45d34bc723f 100644 --- a/peer/core.yaml +++ b/peer/core.yaml @@ -394,9 +394,10 @@ ledger: # CouchDB request timeout (unit: duration, e.g. 20s) requestTimeout: 20s - # historyDatabase - options are true or false - # Indicates if the history of key updates should be stored in goleveldb - historyDatabase: true - # Limit on the number of records to return per query queryLimit: 10000 + + history: + # enableHistoryDatabase - options are true or false + # Indicates if the history of key updates should be stored in goleveldb + enableHistoryDatabase: true