代码拉取完成,页面将自动刷新
/*
Copyright IBM Corp. All Rights Reserved.
SPDX-License-Identifier: Apache-2.0
*/
package peer
import (
"fmt"
"github.com/golang/protobuf/proto"
"github.com/hyperledger/fabric-protos-go/common"
"github.com/hyperledger/fabric/core/ledger"
"github.com/hyperledger/fabric/protoutil"
)
const (
channelConfigKey = "CHANNEL_CONFIG_ENV_BYTES"
peerNamespace = ""
)
// ConfigTxProcessor implements the interface 'github.com/hyperledger/fabric/core/ledger/customtx/Processor'
type ConfigTxProcessor struct{}
// GenerateSimulationResults implements function in the interface 'github.com/hyperledger/fabric/core/ledger/customtx/Processor'
// This implementation processes CONFIG transactions which simply stores the config-envelope-bytes
func (tp *ConfigTxProcessor) GenerateSimulationResults(txEnv *common.Envelope, simulator ledger.TxSimulator, initializingLedger bool) error {
payload := protoutil.UnmarshalPayloadOrPanic(txEnv.Payload)
channelHdr := protoutil.UnmarshalChannelHeaderOrPanic(payload.Header.ChannelHeader)
txType := common.HeaderType(channelHdr.GetType())
switch txType {
case common.HeaderType_CONFIG:
peerLogger.Debugf("Processing CONFIG")
if payload.Data == nil {
return fmt.Errorf("channel config found nil")
}
return simulator.SetState(peerNamespace, channelConfigKey, payload.Data)
default:
return fmt.Errorf("tx type [%s] is not expected", txType)
}
}
func retrieveChannelConfig(queryExecuter ledger.QueryExecutor) (*common.Config, error) {
configBytes, err := queryExecuter.GetState(peerNamespace, channelConfigKey)
if err != nil {
return nil, err
}
if configBytes == nil {
return nil, nil
}
configEnvelope := &common.ConfigEnvelope{}
if err := proto.Unmarshal(configBytes, configEnvelope); err != nil {
return nil, err
}
return configEnvelope.Config, nil
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。