1 Star 0 Fork 0

peter/fabric

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
ledger_config.go 3.36 KB
一键复制 编辑 原始数据 按行查看 历史
/*
Copyright IBM Corp. 2016 All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package ledgerconfig
import (
"path/filepath"
"github.com/spf13/viper"
)
// TODO remove all these config variables, they are never used as defaults
var stateDatabase = "goleveldb"
var couchDBAddress = "127.0.0.1:5984"
var username = ""
var password = ""
var historyDatabase = true
var maxBlockFileSize = 0
// CouchDBDef contains parameters
type CouchDBDef struct {
URL string
Username string
Password string
}
//IsCouchDBEnabled exposes the useCouchDB variable
func IsCouchDBEnabled() bool {
stateDatabase = viper.GetString("ledger.state.stateDatabase")
if stateDatabase == "CouchDB" {
return true
}
return false
}
// GetRootPath returns the filesystem path.
// All ledger related contents are expected to be stored under this path
func GetRootPath() string {
sysPath := viper.GetString("peer.fileSystemPath")
return filepath.Join(sysPath, "ledgersData")
}
// GetLedgerProviderPath returns the filesystem path for stroing ledger ledgerProvider contents
func GetLedgerProviderPath() string {
return filepath.Join(GetRootPath(), "ledgerProvider")
}
// GetStateLevelDBPath returns the filesystem path that is used to maintain the state level db
func GetStateLevelDBPath() string {
return filepath.Join(GetRootPath(), "stateLeveldb")
}
// GetHistoryLevelDBPath returns the filesystem path that is used to maintain the history level db
func GetHistoryLevelDBPath() string {
return filepath.Join(GetRootPath(), "historyLeveldb")
}
// GetBlockStorePath returns the filesystem path that is used for the chain block stores
func GetBlockStorePath() string {
return filepath.Join(GetRootPath(), "chains")
}
// GetMaxBlockfileSize returns maximum size of the block file
func GetMaxBlockfileSize() int {
return 64 * 1024 * 1024
}
//GetCouchDBDefinition exposes the useCouchDB variable
func GetCouchDBDefinition() *CouchDBDef {
couchDBAddress = viper.GetString("ledger.state.couchDBConfig.couchDBAddress")
username = viper.GetString("ledger.state.couchDBConfig.username")
password = viper.GetString("ledger.state.couchDBConfig.password")
return &CouchDBDef{couchDBAddress, username, password}
}
//GetQueryLimit exposes the queryLimit variable
func GetQueryLimit() int {
return viper.GetInt("ledger.state.queryLimit")
}
//IsHistoryDBEnabled exposes the historyDatabase variable
func IsHistoryDBEnabled() bool {
return viper.GetBool("ledger.state.historyDatabase")
}
// IsQueryReadsHashingEnabled enables or disables computing of hash
// of range query results for phantom item validation
func IsQueryReadsHashingEnabled() bool {
return true
}
// GetMaxDegreeQueryReadsHashing return the maximum degree of the merkle tree for hashes of
// of range query results for phantom item validation
// For more details - see description in kvledger/txmgmt/rwset/query_results_helper.go
func GetMaxDegreeQueryReadsHashing() int {
return 50
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/peter_code_git/fabric.git
git@gitee.com:peter_code_git/fabric.git
peter_code_git
fabric
fabric
v1.0.0-alpha

搜索帮助

0d507c66 1850385 C8b1a773 1850385