6 Star 46 Fork 28

Hyperledger/fabric

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
upgrade_dbs.go 1.53 KB
一键复制 编辑 原始数据 按行查看 历史
/*
Copyright IBM Corp. All Rights Reserved.
SPDX-License-Identifier: Apache-2.0
*/
package kvledger
import (
"github.com/hyperledger/fabric/common/ledger/blkstorage/fsblkstorage"
"github.com/hyperledger/fabric/common/ledger/dataformat"
"github.com/hyperledger/fabric/common/ledger/util/leveldbhelper"
"github.com/pkg/errors"
)
// UpgradeDBs upgrades existing ledger databases to the latest formats
func UpgradeDBs(rootFSPath string) error {
fileLockPath := fileLockPath(rootFSPath)
fileLock := leveldbhelper.NewFileLock(fileLockPath)
if err := fileLock.Lock(); err != nil {
return errors.Wrap(err, "as another peer node command is executing,"+
" wait for that command to complete its execution or terminate it before retrying")
}
defer fileLock.Unlock()
logger.Infof("Ledger data folder from config = [%s]", rootFSPath)
// upgrades idStore (ledgerProvider) and drop databases
if err := UpgradeIDStoreFormat(rootFSPath); err != nil {
return err
}
if err := dropDBs(rootFSPath); err != nil {
return err
}
blockstorePath := BlockStorePath(rootFSPath)
return fsblkstorage.DeleteBlockStoreIndex(blockstorePath)
}
// UpgradeIDStoreFormat upgrades the format for idStore
func UpgradeIDStoreFormat(rootFSPath string) error {
logger.Debugf("Attempting to upgrade idStore data format to current format %s", dataformat.Version20)
dbPath := LedgerProviderPath(rootFSPath)
db := leveldbhelper.CreateDB(&leveldbhelper.Conf{DBPath: dbPath})
db.Open()
defer db.Close()
idStore := &idStore{db, dbPath}
return idStore.upgradeFormat()
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/hyperledger/fabric.git
git@gitee.com:hyperledger/fabric.git
hyperledger
fabric
fabric
v2.0.0-beta

搜索帮助