本编我们会基于上篇博文展开实验《向组织org1中添加用户usertest并成功调用链码》
首先我们来理解一下一些基础属于:
1,leader节点
2,锚节点
3,引导节点
leader节点介绍:
一个机构中的主导节点/leader负责从排序服务接收区块并分发给同一机构中的其他peer节点。请记住在一个fabric网络中,所有的peer节点都需要从排序服务接收新区块。leader节点的引入优化了新区块同步到所有peer节点的流程,因为排序服务只需要向每个机构的leader节点发送新区块就可以了,接下来由leader节点负责同步到其他peer节点。
每个机构都有自己的leader节点。在演示中我们将看到这一点。每个通道也都有自己的leader节点。在peer节点加入一个通道之前,它是没有leader这个概念的,只有当它加入通道之后,才涉及leader节点的问题。
在一个机构中,leader节点可以静态配置或者动态选举。在First Network中的默认设置是通过选举决定,该配置在base/peer-base.yaml中:
锚节点介绍:
在一个网络中需要锚节点/anchor peer来获取其他机构的通道成员信息。如果没有锚节点的化,那么对通道成员的了解将局限在当前机构内。例如,当没有锚节点时,在Org1中的peer节点只了解Org1内部的其他peer节点是通道成员,但是没法了解Org2机构内的peer节点也是通道成员。在一个通道中至少需要一个锚节点以打破这种信息的割裂。
锚节点的配置需要对通道进行更新操作。首先使用configtxgen创建一个更新交易,签名该交易并发送给排序服务,排序服务就会生成一个新的配置区块,其中包含了这个用于更新锚节点配置的交易。当这个区块到达通道中所有的peer节点并被各节点提交后,所有的peer节点也就都了解哪个是锚节点了,并进而通过彼此的gossip传播实现了对整个通道成员的信息了解,即包括机构内成员,也包括机构外成员。
在后面部分我们将看到配置锚节点前后的不同运行情况。
引导节点介绍:
Gossip引导节点配置需要在每个对等节点/peer上进行,该配置包含了同一机构中的一个或一组对等节点。当一个peer启动运行后,它就会联络列表中的其他peer节点进行消息的gossip传播。
在经典的First Network配置中,在每个机构中有两个peer节点,因此一个合理的设置就是将另一个peer节点作为gossip的引导节点,这也是我们在配置文件(base/docker-compose-base.yaml)中观察到的。下面只显示了Org1的peer节点的信息,不过我们可以在Org2的peer节点配置中观察到类似的信息:
下面我们来着重讲下设置锚节点的步骤:
实验前请确保你已经完成了文章头部所提到的实验,下面的实验会基于它来完成
我们将设置peer0.org1为org1的锚节点
登录cli,并切换到peer0.org1的环境变量中,我的环境当中cli默认连接的就是peer0.org1,并且登录用户是admin,如图所示:
设置锚节点和添加组织的过程很像,在后续的操作当中你会发些基本流程是一样的都是如下步骤:
1,获取通道交易配置protobuff 文件并将其转换成json格式方便后续更新使用:
1 peer channel fetch config config_block_anchor.pb -o orderer.example.com:7050 -c mychannel 2 configtxlator proto_decode --input config_block_anchor.pb --type common.Block | jq .data.data[0].payload.data.config > config_anchor.json
我们获取了通道交易配置文件并将其转化成json
2,修改配置文件:
首先我们先复制一份配置文件,因为后面我们在计算更新时还会用到老的配置文件
1 cp config_anchor.json config_anchor_updated.json
更新配置文件,有两种方式,第一种是通过jq工具去修改,第二种就是手动去修改,我们采用第一种,后面我会贴出文件的前后变化
1 jq '.channel_group.groups.Application.groups.Org1MSP.values += {"AnchorPeers":{"mod_policy": "Admins","value":{"anchor_peers": [{"host": "peer0.org1.example.com","port": 7051}]},"version": "0"}}' config_anchor_updated.json > modified_config.json
原始文件:
{ "channel_group": { "groups": { "Application": { "groups": { "Org1MSP": { "groups": {}, "mod_policy": "Admins", "policies": { "Admins": { "mod_policy": "Admins", "policy": { "type": 1, "value": { "identities": [ { "principal": { "msp_identifier": "Org1MSP", "role": "ADMIN" }, "principal_classification": "ROLE" } ], "rule": { "n_out_of": { "n": 1, "rules": [ { "signed_by": 0 } ] } }, "version": 0 } }, "version": "0" }, "Readers": { "mod_policy": "Admins", "policy": { "type": 1, "value": { "identities": [ { "principal": { "msp_identifier": "Org1MSP", "role": "MEMBER" }, "principal_classification": "ROLE" } ], "rule": { "n_out_of": { "n": 1, "rules": [ { "signed_by": 0 } ] } }, "version": 0 } }, "version": "0" }, "Writers": { "mod_policy": "Admins", "policy": { "type": 1, "value": { "identities": [ { "principal": { "msp_identifier": "Org1MSP", "role": "MEMBER" }, "principal_classification": "ROLE" } ], "rule": { "n_out_of": { "n": 1, "rules": [ { "signed_by": 0 } ] } }, "version": 0 } }, "version": "0" } }, "values": { "MSP": { "mod_policy": "Admins", "value": { "config": { "admins": [ "LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUNHVENDQWIrZ0F3SUJBZ0lRWGlzbWdPblViVnFwNlpZQ2NMM0lyakFLQmdncWhrak9QUVFEQWpCek1Rc3cKQ1FZRFZRUUdFd0pWVXpFVE1CRUdBMVVFQ0JNS1EyRnNhV1p2Y201cFlURVdNQlFHQTFVRUJ4TU5VMkZ1SUVaeQpZVzVqYVhOamJ6RVpNQmNHQTFVRUNoTVFiM0puTVM1bGVHRnRjR3hsTG1OdmJURWNNQm9HQTFVRUF4TVRZMkV1CmIzSm5NUzVsZUdGdGNHeGxMbU52YlRBZUZ3MHlNREV5TVRZd01qUXpNREJhRncwek1ERXlNVFF3TWpRek1EQmEKTUZzeEN6QUpCZ05WQkFZVEFsVlRNUk13RVFZRFZRUUlFd3BEWVd4cFptOXlibWxoTVJZd0ZBWURWUVFIRXcxVApZVzRnUm5KaGJtTnBjMk52TVI4d0hRWURWUVFEREJaQlpHMXBia0J2Y21jeExtVjRZVzF3YkdVdVkyOXRNRmt3CkV3WUhLb1pJemowQ0FRWUlLb1pJemowREFRY0RRZ0FFMElQKzNvS2FiNllkUEpyU2JJQStOdmdpSFQzckU3NHIKRmU0MUtSUm5RbVAydXIvSEY0cVUrOHBLdTNPS2szdjNtMmszMzJaZDViY0RYb1UrMk5JMXg2Tk5NRXN3RGdZRApWUjBQQVFIL0JBUURBZ2VBTUF3R0ExVWRFd0VCL3dRQ01BQXdLd1lEVlIwakJDUXdJb0FnbnJmUTVOa2hFT0NmCnVuR292MFArN2NxM3ptWkdrNVdSUEtoUk1iZ29yRE13Q2dZSUtvWkl6ajBFQXdJRFNBQXdSUUloQUxCbHViT3oKTDA4WjlpRmxiYVZMZG56UUxjaVNqMmJUWERLbU9NZzRWOWNjQWlCTVk1ZHlGNU1ILzU0MVRtOWtaclYxRzJsLwpFUU5SSEJtb0paeHF1cW9jblE9PQotLS0tLUVORCBDRVJUSUZJQ0FURS0tLS0tCg==" ], "crypto_config": { "identity_identifier_hash_function": "SHA256", "signature_hash_family": "SHA2" }, "fabric_node_ous": null, "intermediate_certs": [], "name": "Org1MSP", "organizational_unit_identifiers": [], "revocation_list": [], "root_certs": [ "LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUNVakNDQWZpZ0F3SUJBZ0lSQUtZc3JWWkhVcGVMTU94Y1dZKzNMNjR3Q2dZSUtvWkl6ajBFQXdJd2N6RUwKTUFrR0ExVUVCaE1DVlZNeEV6QVJCZ05WQkFnVENrTmhiR2xtYjNKdWFXRXhGakFVQmdOVkJBY1REVk5oYmlCRwpjbUZ1WTJselkyOHhHVEFYQmdOVkJBb1RFRzl5WnpFdVpYaGhiWEJzWlM1amIyMHhIREFhQmdOVkJBTVRFMk5oCkxtOXlaekV1WlhoaGJYQnNaUzVqYjIwd0hoY05NakF4TWpFMk1ESTBNekF3V2hjTk16QXhNakUwTURJME16QXcKV2pCek1Rc3dDUVlEVlFRR0V3SlZVekVUTUJFR0ExVUVDQk1LUTJGc2FXWnZjbTVwWVRFV01CUUdBMVVFQnhNTgpVMkZ1SUVaeVlXNWphWE5qYnpFWk1CY0dBMVVFQ2hNUWIzSm5NUzVsZUdGdGNHeGxMbU52YlRFY01Cb0dBMVVFCkF4TVRZMkV1YjNKbk1TNWxlR0Z0Y0d4bExtTnZiVEJaTUJNR0J5cUdTTTQ5QWdFR0NDcUdTTTQ5QXdFSEEwSUEKQkJvd3hpeHpVelh5UWl1dnZjU2pCSThFVUYxTlgzampoMVRuMjNXb1lxSmdZdUhqenJIY0lWQXkzWkUrZHg1KwpLM2NPRUcyaTN6OTF6eVpYVVRSUml2aWpiVEJyTUE0R0ExVWREd0VCL3dRRUF3SUJwakFkQmdOVkhTVUVGakFVCkJnZ3JCZ0VGQlFjREFnWUlLd1lCQlFVSEF3RXdEd1lEVlIwVEFR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SdkpMYkNPNDZPcwpXbDY5RjVjNUgraUpsNTI1SjdxT2FiSkJRSHRZMFN1amJUQnJNQTRHQTFVZER3RUIvd1FFQXdJQnBqQWRCZ05WCkhTVUVGakFVQmdnckJnRUZCUWNEQWdZSUt3WUJCUVVIQXdFd0R3WURWUjBUQVFIL0JBVXdBd0VCL3pBcEJnTlYKSFE0RUlnUWdiTnRvZUh5aXlQZkVST1RhWXkyZk52bmVvOUUwQ0tBbHFLS3dxenVVOENzd0NnWUlLb1pJemowRQpBd0lEUndBd1JBSWdCNHU3eEtZdklrZVlNcmVDYmhGdjFFRlRlRU1BUnNaemE0VjEwMUFoMS9nQ0lDWlA3WkMzCnc3eklrMDVtaVp2SDcwVnlvVnhoblRzZzJLaWJUM2R2UERCZAotLS0tLUVORCBDRVJUSUZJQ0FURS0tLS0tCg==" ] }, "type": 0 }, "version": "0" } }, "version": "0" } }, "mod_policy": "Admins", "policies": { "Admins": { "mod_policy": "Admins", "policy": { "type": 3, "value": { "rule": "MAJORITY", "sub_policy": "Admins" } }, "version": "0" }, "Readers": { "mod_policy": "Admins", "policy": { "type": 3, "value": { "rule": "ANY", "sub_policy": "Readers" } }, "version": "0" }, "Writers": { "mod_policy": "Admins", "policy": { "type": 3, "value": { "rule": "ANY", "sub_policy": "Writers" } }, "version": "0" } }, "values": {}, "version": "2" }, "Orderer": { "groups": { "OrdererOrg": { "groups": {}, "mod_policy": "Admins", "policies": { "Admins": { "mod_policy": "Admins", "policy": { "type": 1, "value": { "identities": [ { "principal": { "msp_identifier": "OrdererMSP", "role": "ADMIN" }, "principal_classification": "ROLE" } ], "rule": { "n_out_of": { "n": 1, "rules": [ { "signed_by": 0 } ] } }, "version": 0 } }, "version": "0" }, "Readers": { "mod_policy": "Admins", "policy": { "type": 1, "value": { "identities": [ { "principal": { "msp_identifier": "OrdererMSP", "role": "MEMBER" }, "principal_classification": "ROLE" } ], "rule": { "n_out_of": { "n": 1, "rules": [ { "signed_by": 0 } ] } }, "version": 0 } }, "version": "0" }, "Writers": { "mod_policy": "Admins", "policy": { "type": 1, "value": { "identities": [ { "principal": { "msp_identifier": "OrdererMSP", "role": "MEMBER" }, "principal_classification": "ROLE" } ], "rule": { "n_out_of": { "n": 1, "rules": [ { "signed_by": 0 } ] } }, "version": 0 } }, "version": "0" } }, "values": { "MSP": { "mod_policy": "Admins", "value": { "config": { "admins": [ "LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUNDakNDQWJHZ0F3SUJBZ0lSQUs0a1loLzJTTnhiTlk4QTh2d3dxdzh3Q2dZSUtvWkl6ajBFQXdJd2FURUwKTUFrR0ExVUVCaE1DVlZNeEV6QVJCZ05WQkFnVENrTmhiR2xtYjNKdWFXRXhGakFVQmdOVkJBY1REVk5oYmlCRwpjbUZ1WTJselkyOHhGREFTQmdOVkJBb1RDMlY0WVcxd2JHVXVZMjl0TVJjd0ZRWURWUVFERXc1allTNWxlR0Z0CmNHeGxMbU52YlRBZUZ3MHlNREV5TVRZd01qUTFNREJhRncwek1ERXlNVFF3TWpRMU1EQmFNRll4Q3pBSkJnTlYKQkFZVEFsVlRNUk13RVFZRFZRUUlFd3BEWVd4cFptOXlibWxoTVJZd0ZBWURWUVFIRXcxVFlXNGdSbkpoYm1OcApjMk52TVJvd0dBWURWUVFEREJGQlpHMXBia0JsZUdGdGNHeGxMbU52YlRCWk1CTUdCeXFHU000OUFnRUdDQ3FHClNNNDlBd0VIQTBJQUJNOE5Ja0RmL3hDeXU2M0YwTSs3UnB0RXZLR0I1cHF5Rjcrazh1bzJsbDNZQmh0VmxOcEEKRXhxcDlVNUNWR3NjRy9jbFV2NExKaWV0ak92MXpaeVllMitqVFRCTE1BNEdBMVVkRHdFQi93UUVBd0lIZ0RBTQpCZ05WSFJNQkFmOEVBakFBTUNzR0ExVWRJd1FrTUNLQUlMUy9wOFAwa1R4Y3F5L0c0dGhySUtHeURBNTNvekVqCkgvcjRaRFlYbHlHb01Bb0dDQ3FHU000OUJBTUNBMGNBTUVRQ0lFWHVnNzViUldkMjFEdzR4ZlBrd1FxVUc1Sm0KM2pUYno2U21NcGozM2FSVkFpQkpGQTJHMmZ2MFBaTHl0Vmh0bDNMb0labHlTZmxxOTZ5MjA1V0EvTk8wV2c9PQotLS0tLUVORCBDRVJUSUZJQ0FURS0tLS0tCg==" ], "crypto_config": { "identity_identifier_hash_function": "SHA256", "signature_hash_family": "SHA2" }, "fabric_node_ous": null, "intermediate_certs": [], "name": "OrdererMSP", "organizational_unit_identifiers": [], "revocation_list": [], "root_certs": [ "LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUNQVENDQWVPZ0F3SUJBZ0lRVVJpbngwOS9ldkpsVzFCb0g3ZW4xakFLQmdncWhrak9QUVFEQWpCcE1Rc3cKQ1FZRFZRUUdFd0pWVXpFVE1CRUdBMVVFQ0JNS1EyRnNhV1p2Y201cFlURVdNQlFHQTFVRUJ4TU5VMkZ1SUVaeQpZVzVqYVhOamJ6RVVNQklHQTFVRUNoTUxaWGhoYlhCc1pTNWpiMjB4RnpBVkJnTlZCQU1URG1OaExtVjRZVzF3CmJHVXVZMjl0TUI0WERUSXdNVEl4TmpBeU5EVXdNRm9YRFRNd01USXhOREF5TkRVd01Gb3dhVEVMTUFrR0ExVUUKQmhNQ1ZWTXhFekFSQmdOVkJBZ1RDa05oYkdsbWIzSnVhV0V4RmpBVUJnTlZCQWNURFZOaGJpQkdjbUZ1WTJsegpZMjh4RkRBU0JnTlZCQW9UQzJWNFlXMXdiR1V1WTI5dE1SY3dGUVlEVlFRREV3NWpZUzVsZUdGdGNHeGxMbU52CmJUQlpNQk1HQnlxR1NNNDlBZ0VHQ0NxR1NNNDlBd0VIQTBJQUJJem1WYVl5cEtPSHdZTzNSZG1LbkpwUnFRMWoKMGpROHRoWXQxN2lma25QdnREQ0lLU2g1WlJ2YkhHRlpTNzRVK3VNRTdnRG9nelliRU5OYzhpY1Q1SU9qYlRCcgpNQTRHQTFVZER3RUIvd1FFQXd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zMGwwU29MWlNubUYyNWpIL0lFWkdTTkJLc21zNGsyTTdBaVhOWUc1T0MvR2cvYlhaSGlpL3l2cldZaWxsOQowdVg2bzIwd2F6QU9CZ05WSFE4QkFmOEVCQU1DQWFZd0hRWURWUjBsQkJZd0ZBWUlLd1lCQlFVSEF3SUdDQ3NHCkFRVUZCd01CTUE4R0ExVWRFd0VCL3dRRk1BTUJBZjh3S1FZRFZSME9CQ0lFSU9mcUpISzB1MzNSWTFGVFRoc0YKanEwa0xTS3YzNFBmbFlFYmJaV3FSNGpyTUFvR0NDcUdTTTQ5QkFNQ0EwY0FNRVFDSUFSTEdFYzZuT0lwb2g5MApGWnROcEdLWC9hSjZ2NlZBeEdJVkZFaGU0YTUzQWlCQXkwY050ZEV5cWFYVklrMitqZ1RvOTBWanBkMWduSGRWCi9yMXVRbVhBQ1E9PQotLS0tLUVORCBDRVJUSUZJQ0FURS0tLS0tCg==" ] }, "type": 0 }, "version": "0" } }, "version": "0" } }, "mod_policy": "Admins", "policies": { "Admins": { "mod_policy": "Admins", "policy": { "type": 3, "value": { "rule": "MAJORITY", "sub_policy": "Admins" } }, "version": "0" }, "BlockValidation": { "mod_policy": "Admins", "policy": { "type": 3, "value": { "rule": "ANY", "sub_policy": "Writers" } }, "version": "0" }, "Readers": { "mod_policy": "Admins", "policy": { "type": 3, "value": { "rule": "ANY", "sub_policy": "Readers" } }, "version": "0" }, "Writers": { "mod_policy": "Admins", "policy": { "type": 3, "value": { "rule": "ANY", "sub_policy": "Writers" } }, "version": "0" } }, "values": { "BatchSize": { "mod_policy": "Admins", "value": { "absolute_max_bytes": 102760448, "max_message_count": 10, "preferred_max_bytes": 524288 }, "version": "0" }, "BatchTimeout": { "mod_policy": "Admins", "value": { "timeout": "2s" }, "version": "0" }, "ChannelRestrictions": { "mod_policy": "Admins", "value": null, "version": "0" }, "ConsensusType": { "mod_policy": "Admins", "value": { "metadata": null, "state": "STATE_NORMAL", "type": "solo" }, "version": "0" } }, "version": "0" } }, "mod_policy": "", "policies": { "Admins": { "mod_policy": "Admins", "policy": { "type": 3, "value": { "rule": "MAJORITY", "sub_policy": "Admins" } }, "version": "0" }, "Readers": { "mod_policy": "Admins", "policy": { "type": 3, "value": { "rule": "ANY", "sub_policy": "Readers" } }, "version": "0" }, "Writers": { "mod_policy": "Admins", "policy": { "type": 3, "value": { "rule": "ANY", "sub_policy": "Writers" } }, "version": "0" } }, "values": { "BlockDataHashingStructure": { "mod_policy": "Admins", "value": { "width": 4294967295 }, "version": "0" }, "Consortium": { "mod_policy": "Admins", "value": { "name": "SampleConsortium" }, "version": "0" }, "HashingAlgorithm": { "mod_policy": "Admins", "value": { "name": "SHA256" }, "version": "0" }, "OrdererAddresses": { "mod_policy": "/Channel/Orderer/Admins", "value": { "addresses": [ "orderer.example.com:7050" ] }, "version": "0" } }, "version": "0" }, "sequence": "2" }
更新后的文件:
{ "channel_group": { "groups": { "Application": { "groups": { "Org1MSP": { "groups": {}, "mod_policy": "Admins", "policies": { "Admins": { "mod_policy": "Admins", "policy": { "type": 1, "value": { "identities": [ { "principal": { "msp_identifier": "Org1MSP", "role": "ADMIN" }, "principal_classification": "ROLE" } ], "rule": { "n_out_of": { "n": 1, "rules": [ { "signed_by": 0 } ] } }, "version": 0 } }, "version": "0" }, "Readers": { "mod_policy": "Admins", "policy": { "type": 1, "value": { "identities": [ { "principal": { "msp_identifier": "Org1MSP", "role": "MEMBER" }, "principal_classification": "ROLE" } ], "rule": { "n_out_of": { "n": 1, "rules": [ { "signed_by": 0 } ] } }, "version": 0 } }, "version": "0" }, "Writers": { "mod_policy": "Admins", "policy": { "type": 1, "value": { "identities": [ { "principal": { "msp_identifier": "Org1MSP", "role": "MEMBER" }, "principal_classification": "ROLE" } ], "rule": { "n_out_of": { "n": 1, "rules": [ { "signed_by": 0 } ] } }, "version": 0 } }, "version": "0" } }, "values": { "MSP": { "mod_policy": "Admins", "value": { "config": { "admins": [ "LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tC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QmdnckJnRUZCUWNEQWdZSUt3WUJCUVVIQXdFd0R3WURWUjBUQVFIL0JBVXdBd0VCL3pBcEJnTlYKSFE0RUlnUWdiTnRvZUh5aXlQZkVST1RhWXkyZk52bmVvOUUwQ0tBbHFLS3dxenVVOENzd0NnWUlLb1pJemowRQpBd0lEUndBd1JBSWdCNHU3eEtZdklrZVlNcmVDYmhGdjFFRlRlRU1BUnNaemE0VjEwMUFoMS9nQ0lDWlA3WkMzCnc3eklrMDVtaVp2SDcwVnlvVnhoblRzZzJLaWJUM2R2UERCZAotLS0tLUVORCBDRVJUSUZJQ0FURS0tLS0tCg==" ] }, "type": 0 }, "version": "0" }, "AnchorPeers": { "mod_policy": "Admins", "value": { "anchor_peers": [ { "host": "peer0.org1.example.com", "port": 7051 } ] }, "version": "0" } }, "version": "0" } }, "mod_policy": "Admins", "policies": { "Admins": { "mod_policy": "Admins", "policy": { "type": 3, "value": { "rule": "MAJORITY", "sub_policy": "Admins" } }, "version": "0" }, "Readers": { "mod_policy": "Admins", "policy": { "type": 3, "value": { "rule": "ANY", "sub_policy": "Readers" } }, "version": "0" }, "Writers": { "mod_policy": "Admins", "policy": { "type": 3, "value": { "rule": "ANY", "sub_policy": "Writers" } }, "version": "0" } }, "values": {}, "version": "2" }, "Orderer": { "groups": { "OrdererOrg": { "groups": {}, "mod_policy": "Admins", "policies": { "Admins": { "mod_policy": "Admins", "policy": { "type": 1, "value": { "identities": [ { "principal": { "msp_identifier": "OrdererMSP", "role": "ADMIN" }, "principal_classification": "ROLE" } ], "rule": { "n_out_of": { "n": 1, "rules": [ { "signed_by": 0 } ] } }, "version": 0 } }, "version": "0" }, "Readers": { "mod_policy": "Admins", "policy": { "type": 1, "value": { "identities": [ { "principal": { "msp_identifier": "OrdererMSP", "role": "MEMBER" }, "principal_classification": "ROLE" } ], "rule": { "n_out_of": { "n": 1, "rules": [ { "signed_by": 0 } ] } }, "version": 0 } }, "version": "0" }, "Writers": { "mod_policy": "Admins", "policy": { "type": 1, "value": { "identities": [ { "principal": { "msp_identifier": "OrdererMSP", "role": "MEMBER" }, "principal_classification": "ROLE" } ], "rule": { "n_out_of": { "n": 1, "rules": [ { "signed_by": 0 } ] } }, "version": 0 } }, "version": "0" } }, "values": { "MSP": { "mod_policy": "Admins", "value": { "config": { "admins": [ "LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUNDakNDQWJHZ0F3SUJBZ0lSQUs0a1loLzJTTnhiTlk4QTh2d3dxdzh3Q2dZSUtvWkl6ajBFQXdJd2FURUwKTUFrR0ExVUVCaE1DVlZNeEV6QVJCZ05WQkFnVENrTmhiR2xtYjNKdWFXRXhGakFVQmdOVkJBY1REVk5oYmlCRwpjbUZ1WTJselkyOHhGREFTQmdOVkJBb1RDMlY0WVcxd2JHVXVZMjl0TVJjd0ZRWURWUVFERXc1allTNWxlR0Z0CmNHeGxMbU52YlRBZUZ3MHlNREV5TVRZd01qUTFNREJhRncwek1ERXlNVFF3TWpRMU1EQmFNRll4Q3pBSkJnTlYKQkFZVEFsVlRNUk13RVFZRFZRUUlFd3BEWVd4cFptOXlibWxoTVJZd0ZBWURWUVFIRXcxVFlXNGdSbkpoYm1OcApjMk52TVJvd0dBWURWUVFEREJGQlpHMXBia0JsZUdGdGNHeGxMbU52YlRCWk1CTUdCeXFHU000OUFnRUdDQ3FHClNNNDlBd0VIQTBJQUJNOE5Ja0RmL3hDeXU2M0YwTSs3UnB0RXZLR0I1cHF5Rjcrazh1bzJsbDNZQmh0VmxOcEEKRXhxcDlVNUNWR3NjRy9jbFV2NExKaWV0ak92MXpaeVllMitqVFRCTE1BNEdBMVVkRHdFQi93UUVBd0lIZ0RBTQpCZ05WSFJNQkFmOEVBakFBTUNzR0ExVWRJd1FrTUNLQUlMUy9wOFAwa1R4Y3F5L0c0dGhySUtHeURBNTNvekVqCkgvcjRaRFlYbHlHb01Bb0dDQ3FHU000OUJBTUNBMGNBTUVRQ0lFWHVnNzViUldkMjFEdzR4ZlBrd1FxVUc1Sm0KM2pUYno2U21NcGozM2FSVkFpQkpGQTJHMmZ2MFBaTHl0Vmh0bDNMb0labHlTZmxxOTZ5MjA1V0EvTk8wV2c9PQotLS0tLUVORCBDRVJUSUZJQ0FURS0tLS0tCg==" ], "crypto_config": { "identity_identifier_hash_function": "SHA256", "signature_hash_family": "SHA2" }, "fabric_node_ous": null, "intermediate_certs": [], "name": "OrdererMSP", "organizational_unit_identifiers": [], "revocation_list": [], "root_certs": [ "LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUNQVENDQWVPZ0F3SUJBZ0lRVVJpbngwOS9ldkpsVzFCb0g3ZW4xakFLQmdncWhrak9QUVFEQWpCcE1Rc3cKQ1FZRFZRUUdFd0pWVXpFVE1CRUdBMVVFQ0JNS1EyRnNhV1p2Y201cFlURVdNQlFHQTFVRUJ4TU5VMkZ1SUVaeQpZVzVqYVhOamJ6RVVNQklHQTFVRUNoTUxaWGhoYlhCc1pTNWpiMjB4RnpBVkJnTlZCQU1URG1OaExtVjRZVzF3CmJHVXVZMjl0TUI0WERUSXdNVEl4TmpBeU5EVXdNRm9YRFRNd01USXhOREF5TkRVd01Gb3dhVEVMTUFrR0ExVUUKQmhNQ1ZWTXhFekFSQmdOVkJBZ1RDa05oYkdsbWIzSnVhV0V4RmpBVUJnTlZCQWNURFZOaGJpQkdjbUZ1WTJsegpZMjh4RkRBU0JnTlZCQW9UQzJWNFlXMXdiR1V1WTI5dE1SY3dGUVlEVlFRREV3NWpZUzVsZUdGdGNHeGxMbU52CmJUQlpNQk1HQnlxR1NNNDlBZ0VHQ0NxR1NNNDlBd0VIQTBJQUJJem1WYVl5cEtPSHdZTzNSZG1LbkpwUnFRMWoKMGpROHRoWXQxN2lma25QdnREQ0lLU2g1WlJ2YkhHRlpTNzRVK3VNRTdnRG9nelliRU5OYzhpY1Q1SU9qYlRCcgpNQTRHQTFVZER3RUIvd1FFQXdJQnBqQWRCZ05WSFNVRUZqQVVCZ2dyQmdFRkJ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yTTdBaVhOWUc1T0MvR2cvYlhaSGlpL3l2cldZaWxsOQowdVg2bzIwd2F6QU9CZ05WSFE4QkFmOEVCQU1DQWFZd0hRWURWUjBsQkJZd0ZBWUlLd1lCQlFVSEF3SUdDQ3NHCkFRVUZCd01CTUE4R0ExVWRFd0VCL3dRRk1BTUJBZjh3S1FZRFZSME9CQ0lFSU9mcUpISzB1MzNSWTFGVFRoc0YKanEwa0xTS3YzNFBmbFlFYmJaV3FSNGpyTUFvR0NDcUdTTTQ5QkFNQ0EwY0FNRVFDSUFSTEdFYzZuT0lwb2g5MApGWnROcEdLWC9hSjZ2NlZBeEdJVkZFaGU0YTUzQWlCQXkwY050ZEV5cWFYVklrMitqZ1RvOTBWanBkMWduSGRWCi9yMXVRbVhBQ1E9PQotLS0tLUVORCBDRVJUSUZJQ0FURS0tLS0tCg==" ] }, "type": 0 }, "version": "0" } }, "version": "0" } }, "mod_policy": "Admins", "policies": { "Admins": { "mod_policy": "Admins", "policy": { "type": 3, "value": { "rule": "MAJORITY", "sub_policy": "Admins" } }, "version": "0" }, "BlockValidation": { "mod_policy": "Admins", "policy": { "type": 3, "value": { "rule": "ANY", "sub_policy": "Writers" } }, "version": "0" }, "Readers": { "mod_policy": "Admins", "policy": { "type": 3, "value": { "rule": "ANY", "sub_policy": "Readers" } }, "version": "0" }, "Writers": { "mod_policy": "Admins", "policy": { "type": 3, "value": { "rule": "ANY", "sub_policy": "Writers" } }, "version": "0" } }, "values": { "BatchSize": { "mod_policy": "Admins", "value": { "absolute_max_bytes": 102760448, "max_message_count": 10, "preferred_max_bytes": 524288 }, "version": "0" }, "BatchTimeout": { "mod_policy": "Admins", "value": { "timeout": "2s" }, "version": "0" }, "ChannelRestrictions": { "mod_policy": "Admins", "value": null, "version": "0" }, "ConsensusType": { "mod_policy": "Admins", "value": { "metadata": null, "state": "STATE_NORMAL", "type": "solo" }, "version": "0" } }, "version": "0" } }, "mod_policy": "", "policies": { "Admins": { "mod_policy": "Admins", "policy": { "type": 3, "value": { "rule": "MAJORITY", "sub_policy": "Admins" } }, "version": "0" }, "Readers": { "mod_policy": "Admins", "policy": { "type": 3, "value": { "rule": "ANY", "sub_policy": "Readers" } }, "version": "0" }, "Writers": { "mod_policy": "Admins", "policy": { "type": 3, "value": { "rule": "ANY", "sub_policy": "Writers" } }, "version": "0" } }, "values": { "BlockDataHashingStructure": { "mod_policy": "Admins", "value": { "width": 4294967295 }, "version": "0" }, "Consortium": { "mod_policy": "Admins", "value": { "name": "SampleConsortium" }, "version": "0" }, "HashingAlgorithm": { "mod_policy": "Admins", "value": { "name": "SHA256" }, "version": "0" }, "OrdererAddresses": { "mod_policy": "/Channel/Orderer/Admins", "value": { "addresses": [ "orderer.example.com:7050" ] }, "version": "0" } }, "version": "0" }, "sequence": "2" }
3,计算通道配置更细:
1 configtxlator proto_encode --input config_anchor.json --type common.Config --output config_anchor.pb 2 configtxlator proto_encode --input modified_config.json --type common.Config --output modified_config.pb 3 configtxlator compute_update --channel_id mychannel --original config_anchor.pb --updated modified_config.pb --output config_update.pb
4,为更新封装信封头,并生成新的protobuff文件
1 configtxlator proto_decode --input config_update.pb --type common.ConfigUpdate --output config_update.json 2 echo '{"payload":{"header":{"channel_header":{"channel_id":"mychannel", "type":2}},"data":{"config_update":'$(cat config_update.json)'}}}' | jq . > config_update_in_envelope.json 3 configtxlator proto_encode --input config_update_in_envelope.json --type common.Envelope --output config_update_in_envelope.pb
5,向order提交更新通道操作:
1 peer channel update -f config_update_in_envelope.pb -o orderer.example.com:7050 -c mychannel
成功后会出现下面的结果:
再次确认是否已经成功更次可使用下面的命令:
1 peer channel getinfo -c mychannel
至此我们已经将peer0.org1设置为组织org1的锚节点,其他组织的设置依次安装此方法
参考文档:
https://developer.aliyun.com/article/769612?spm=a2c6h.14164896.0.0.167a1219cOBn0T