1 Star 0 Fork 0

妥協/fabric

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
pause_resume.go 1.43 KB
一键复制 编辑 原始数据 按行查看 历史
/*
Copyright IBM Corp. All Rights Reserved.
SPDX-License-Identifier: Apache-2.0
*/
package kvledger
import (
"github.com/hyperledger/fabric/common/ledger/util/leveldbhelper"
"github.com/hyperledger/fabric/core/ledger/kvledger/msgs"
"github.com/pkg/errors"
)
// PauseChannel updates the channel status to inactive in ledgerProviders.
func PauseChannel(rootFSPath, ledgerID string) error {
if err := pauseOrResumeChannel(rootFSPath, ledgerID, msgs.Status_INACTIVE); err != nil {
return err
}
logger.Infof("The channel [%s] has been successfully paused", ledgerID)
return nil
}
// ResumeChannel updates the channel status to active in ledgerProviders
func ResumeChannel(rootFSPath, ledgerID string) error {
if err := pauseOrResumeChannel(rootFSPath, ledgerID, msgs.Status_ACTIVE); err != nil {
return err
}
logger.Infof("The channel [%s] has been successfully resumed", ledgerID)
return nil
}
func pauseOrResumeChannel(rootFSPath, ledgerID string, status msgs.Status) error {
fileLock := leveldbhelper.NewFileLock(fileLockPath(rootFSPath))
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()
idStore, err := openIDStore(LedgerProviderPath(rootFSPath))
if err != nil {
return err
}
defer idStore.db.Close()
return idStore.updateLedgerStatus(ledgerID, status)
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/liurenhao/fabric.git
git@gitee.com:liurenhao/fabric.git
liurenhao
fabric
fabric
v2.0.0-beta

搜索帮助