代码拉取完成,页面将自动刷新
/*
Copyright IBM Corp. All Rights Reserved.
SPDX-License-Identifier: Apache-2.0
*/
package kvledger
import (
"gitee.com/hyperledger-fabric-gm/fabric/common/ledger/util/leveldbhelper"
"gitee.com/hyperledger-fabric-gm/fabric/core/ledger/ledgerconfig"
"gitee.com/hyperledger-fabric-gm/fabric/core/ledger/ledgerstorage"
"github.com/pkg/errors"
)
// RollbackKVLedger rollbacks a ledger to a specified block number
func RollbackKVLedger(ledgerID string, blockNum uint64) error {
fileLock := leveldbhelper.NewFileLock(ledgerconfig.GetFileLockPath())
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()
blockstorePath := ledgerconfig.GetBlockStorePath()
if err := ledgerstorage.ValidateRollbackParams(blockstorePath, ledgerID, blockNum); err != nil {
return err
}
logger.Infof("Dropping databases")
if err := dropDBs(); err != nil {
return err
}
logger.Info("Rolling back ledger store")
if err := ledgerstorage.Rollback(blockstorePath, ledgerID, blockNum); err != nil {
return err
}
logger.Infof("The channel [%s] has been successfully rolled back to the block number [%d]", ledgerID, blockNum)
return nil
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。