1 Star 0 Fork 0

peter / fabric

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
drop_dbs.go 2.36 KB
一键复制 编辑 原始数据 按行查看 历史
/*
Copyright IBM Corp. All Rights Reserved.
SPDX-License-Identifier: Apache-2.0
*/
package kvledger
import (
"os"
"github.com/hyperledger/fabric/core/ledger/ledgerconfig"
"github.com/pkg/errors"
)
func dropDBs() error {
// During block commits to stateDB, the transaction manager updates the bookkeeperDB and one of the
// state listener updates the config historyDB. As we drop the stateDB, we need to drop the
// configHistoryDB and bookkeeperDB too so that during the peer startup after the reset/rollback,
// we can get a correct configHistoryDB.
// Note that it is necessary to drop the stateDB first before dropping the config history and
// bookkeeper. Suppose if the config or bookkeeper is dropped first and the peer reset/rollback
// command fails before dropping the stateDB, peer cannot start with consistent data (if the
// user decides to start the peer without retrying the reset/rollback) as the stateDB would
// not be rebuilt.
if err := dropStateLevelDB(); err != nil {
return err
}
if err := dropConfigHistoryDB(); err != nil {
return err
}
if err := dropBookkeeperDB(); err != nil {
return err
}
if err := dropHistoryDB(); err != nil {
return err
}
return nil
}
func dropStateLevelDB() error {
stateLeveldbPath := ledgerconfig.GetStateLevelDBPath()
logger.Infof("Dropping StateLevelDB at location [%s]", stateLeveldbPath)
err := os.RemoveAll(stateLeveldbPath)
return errors.Wrapf(err, "error removing the StateLevelDB located at %s", stateLeveldbPath)
}
func dropConfigHistoryDB() error {
configHistoryDBPath := ledgerconfig.GetConfigHistoryPath()
logger.Infof("Dropping ConfigHistoryDB at location [%s]", configHistoryDBPath)
err := os.RemoveAll(configHistoryDBPath)
return errors.Wrapf(err, "error removing the ConfigHistoryDB located at %s", configHistoryDBPath)
}
func dropBookkeeperDB() error {
bookkeeperDBPath := ledgerconfig.GetInternalBookkeeperPath()
logger.Infof("Dropping BookkeeperDB at location [%s]", bookkeeperDBPath)
err := os.RemoveAll(bookkeeperDBPath)
return errors.Wrapf(err, "error removing the BookkeeperDB located at %s", bookkeeperDBPath)
}
func dropHistoryDB() error {
histroryDBPath := ledgerconfig.GetHistoryLevelDBPath()
logger.Infof("Dropping HistoryDB at location [%s]", histroryDBPath)
err := os.RemoveAll(histroryDBPath)
return errors.Wrapf(err, "error removing the HistoryDB located at %s", histroryDBPath)
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/peter_code_git/fabric.git
git@gitee.com:peter_code_git/fabric.git
peter_code_git
fabric
fabric
v1.4.6

搜索帮助

344bd9b3 5694891 D2dac590 5694891