代码拉取完成,页面将自动刷新
/*
Copyright IBM Corp. All Rights Reserved.
SPDX-License-Identifier: Apache-2.0
*/
package statebased
import (
commonerrors "github.com/hyperledger/fabric/common/errors"
validation "github.com/hyperledger/fabric/core/handlers/validation/api/policies"
"github.com/hyperledger/fabric/protoutil"
"github.com/pkg/errors"
)
// NewV13Evaluator returns a policy evaluator that checks
// 2 kinds of policies:
// 1) chaincode endorsement policies;
// 2) state-based endorsement policies.
func NewV13Evaluator(policySupport validation.PolicyEvaluator, vpmgr KeyLevelValidationParameterManager) *policyCheckerFactoryV13 {
return &policyCheckerFactoryV13{
policySupport: policySupport,
vpmgr: vpmgr,
}
}
type policyCheckerFactoryV13 struct {
vpmgr KeyLevelValidationParameterManager
policySupport validation.PolicyEvaluator
}
func (p *policyCheckerFactoryV13) Evaluator(ccEP []byte) RWSetPolicyEvaluator {
return &baseEvaluator{
epEvaluator: &policyCheckerV13{
policySupport: p.policySupport,
ccEP: ccEP,
},
vpmgr: p.vpmgr,
policySupport: p.policySupport,
}
}
/**********************************************************************************************************/
/**********************************************************************************************************/
type policyCheckerV13 struct {
someEPChecked bool
ccEPChecked bool
policySupport validation.PolicyEvaluator
ccEP []byte
}
func (p *policyCheckerV13) checkCCEPIfCondition(cc string, blockNum, txNum uint64, condition bool, sd []*protoutil.SignedData) commonerrors.TxValidationError {
if condition {
return nil
}
// validate against cc ep
err := p.policySupport.Evaluate(p.ccEP, sd)
if err != nil {
return policyErr(errors.Wrapf(err, "validation of endorsement policy for chaincode %s in tx %d:%d failed", cc, blockNum, txNum))
}
p.ccEPChecked = true
p.someEPChecked = true
return nil
}
func (p *policyCheckerV13) CheckCCEPIfNotChecked(cc, coll string, blockNum, txNum uint64, sd []*protoutil.SignedData) commonerrors.TxValidationError {
return p.checkCCEPIfCondition(cc, blockNum, txNum, p.ccEPChecked, sd)
}
func (p *policyCheckerV13) CheckCCEPIfNoEPChecked(cc string, blockNum, txNum uint64, sd []*protoutil.SignedData) commonerrors.TxValidationError {
return p.checkCCEPIfCondition(cc, blockNum, txNum, p.someEPChecked, sd)
}
func (p *policyCheckerV13) SBEPChecked() {
p.someEPChecked = true
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。