Fabric动态更新出块策略
Fabric中更新出块策略主要分为三步:1.获取通道配置信息;2.修改配置;3.应用和提交修改。
一、获取通道配置信息
- 进入peer节点的cli容器
docker exec -it $cli_name bash
- 获取通道配置
peer channel fetch config config_block.pb -o $ORDERER_CONTAINER -c mychannel --tls --cafile $TLS_ROOT_CA
config_block.pb为获取的文件;orderer容器要加端口号;TLS_ROOT_CA必须是orderer节点的。 - 将获取的文件转换为json格式
configtxlator proto_decode --input config_block.pb --type common.Block --output config_block.json
- 简化文件内容,输出为config.json
jq .data.data[0].payload.data.config config_block.json > config.json
二、修改配置
拷贝config.json为modified_config.json修改,便于比较
三、应用和提交修改
1.将config.json和modified_config.json恢复为pb格式,并比较两者测差别:config_update.pb
configtxlator proto_encode --input config.json --type common.Config --output config.pb
configtxlator proto_encode --input modified_config.json --type common.Config --output modified_config.pb
configtxlator compute_update --channel_id mychannel --original config.pb --updated modified_config.pb --output config_update.pb
- 将差异应用与配置
configtxlator proto_decode --input config_update.pb --type common.ConfigUpdate --output config_update.json
- 将差异配置重新编码
echo '{"payload":{"header":{"channel_header":{"channel_id":"mychannel", "type":2}},"data":{"config_update":'$(cat config_update.json)'}}}' | jq . > config_update_in_envelope.json
configtxlator proto_encode --input config_update_in_envelope.json --type common.Envelope --output config_update_in_envelope.pb
- 提交配置(需要切换环境变量)此处是重点,取配置信息时需要使用对等节点的身份,更新配置时需要使用排序节点的身份。
CORE_PEER_LOCALMSPID=OrdererMSP
CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/users/Admin@example.com/msp/
(根据自己的实际配置)
提交peer channel update -f config_update_in_envelope.pb -c mychannel -o $ORDERER_CONTAINER --tls true --cafile $TLS_ROOT_CA
更新成功!
标签:
Blockchain
, fabric
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】博客园社区专享云产品让利特惠,阿里云新客6.5折上折
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 在鹅厂做java开发是什么体验
· 百万级群聊的设计实践
· WPF到Web的无缝过渡:英雄联盟客户端的OpenSilver迁移实战
· 永远不要相信用户的输入:从 SQL 注入攻防看输入验证的重要性
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
2021-07-13 Rancher离线部署v2.5
2020-07-13 Zabbix监控进程的内存占用和CPU使用率
2017-07-13 Http压测工具wrk使用指南