From a71f632304157ba1082a9d49cfb52a3c03c710f5 Mon Sep 17 00:00:00 2001 From: nkalichynskyi Date: Thu, 13 Aug 2020 08:21:11 +0300 Subject: [PATCH 1/2] Added deocde flag to get_channel_config_with_orderer method to have an ability to fetch config without decoding Signed-off-by: nkalichynskyi --- hfc/fabric/channel/channel.py | 16 ++++++++++------ hfc/fabric/client.py | 6 ++++-- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/hfc/fabric/channel/channel.py b/hfc/fabric/channel/channel.py index 7634dff9..a9c6d6cb 100644 --- a/hfc/fabric/channel/channel.py +++ b/hfc/fabric/channel/channel.py @@ -929,7 +929,7 @@ def get_channel_config(self, tx_context, peers, tx_context.tx_prop_req = request return self.send_tx_proposal(tx_context, peers) - async def get_channel_config_with_orderer(self, tx_context, orderer): + async def get_channel_config_with_orderer(self, tx_context, orderer, decode=True): """Query the current config block for this channel :param tx_context: tx_context instance @@ -974,9 +974,8 @@ async def get_channel_config_with_orderer(self, tx_context, orderer): block = v.block break - block = BlockDecoder().decode(block.SerializeToString()) - - last_config = block['metadata']['metadata'][common_pb2.LAST_CONFIG] + decoded_block = BlockDecoder().decode(block.SerializeToString()) + last_config = decoded_block['metadata']['metadata'][common_pb2.LAST_CONFIG] # if nor first block if 'index' in last_config['value']: @@ -996,9 +995,14 @@ async def get_channel_config_with_orderer(self, tx_context, orderer): block = v.block break - block = BlockDecoder().decode(block.SerializeToString()) + if not decode: + return block.SerializeToString() + decoded_block = BlockDecoder().decode(block.SerializeToString()) + + if not decode: + return block.SerializeToString() - envelope = block['data']['data'][0] + envelope = decoded_block['data']['data'][0] payload = envelope['payload'] channel_header = payload['header']['channel_header'] diff --git a/hfc/fabric/client.py b/hfc/fabric/client.py index a15d00e1..b3d8d286 100644 --- a/hfc/fabric/client.py +++ b/hfc/fabric/client.py @@ -761,7 +761,8 @@ async def get_channel_config(self, requestor, channel_name, async def get_channel_config_with_orderer(self, requestor, channel_name, - orderer=None): + orderer=None, + decode=True): """ Get configuration block for the channel with the orderer @@ -788,7 +789,8 @@ async def get_channel_config_with_orderer(self, requestor, config_envelope = await channel.get_channel_config_with_orderer( tx_context, - target_orderer) + target_orderer, + decode) return config_envelope From d9f9b7624e9ac4193bd5a139bdd246763d5765f1 Mon Sep 17 00:00:00 2001 From: nkalichynskyi Date: Tue, 25 Aug 2020 10:10:14 +0300 Subject: [PATCH 2/2] fixed issue with missing latest tag for fabric-ccenv image Signed-off-by: nkalichynskyi --- test/fixtures/peer-base.yaml | 1 + test/fixtures/peer-mutual-tls.yaml | 1 + 2 files changed, 2 insertions(+) diff --git a/test/fixtures/peer-base.yaml b/test/fixtures/peer-base.yaml index b62db813..5119e7da 100644 --- a/test/fixtures/peer-base.yaml +++ b/test/fixtures/peer-base.yaml @@ -12,6 +12,7 @@ services: peer-base: image: hyperledger/fabric-peer:${HLF_VERSION} environment: + - CORE_CHAINCODE_BUILDER=hyperledger/fabric-ccenv:1.4.6 - GODEBUG=netdns=go+1 - FABRIC_LOGGING_SPEC=debug #- CORE_PEER_ID=peer0 diff --git a/test/fixtures/peer-mutual-tls.yaml b/test/fixtures/peer-mutual-tls.yaml index 5172d0e0..65b130b5 100644 --- a/test/fixtures/peer-mutual-tls.yaml +++ b/test/fixtures/peer-mutual-tls.yaml @@ -12,6 +12,7 @@ services: peer-base: image: hyperledger/fabric-peer:${HLF_VERSION} environment: + - CORE_CHAINCODE_BUILDER=hyperledger/fabric-ccenv:1.4.6 - GODEBUG=netdns=go+1 - FABRIC_LOGGING_SPEC=debug #- CORE_PEER_ID=peer0