Skip to content

Commit

Permalink
[FAB-3185] move historyDatabase to ledger in core.yaml
Browse files Browse the repository at this point in the history
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 <chris.elder@us.ibm.com>
  • Loading branch information
Chris Elder committed Apr 18, 2017
1 parent 7f336b9 commit 5e0f280
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 15 deletions.
10 changes: 5 additions & 5 deletions core/chaincode/chaincodetest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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


################################################################################
#
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
2 changes: 1 addition & 1 deletion core/ledger/ledgerconfig/ledger_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions core/ledger/ledgerconfig/ledger_config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,15 +69,15 @@ 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
}

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
}
Expand Down
2 changes: 1 addition & 1 deletion core/ledger/testutil/test_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 5 additions & 4 deletions peer/core.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 5e0f280

Please sign in to comment.