Skip to content

Commit

Permalink
Added deocde flag to get_channel_config_with_orderer (hyperledger#105)
Browse files Browse the repository at this point in the history
* Added deocde flag to get_channel_config_with_orderer method to have an ability to fetch config without decoding

Signed-off-by: nkalichynskyi <[email protected]>

* fixed issue with missing latest tag for fabric-ccenv image

Signed-off-by: nkalichynskyi <[email protected]>
  • Loading branch information
nkalichynskyi authored and RohanShrothrium committed Aug 26, 2020
1 parent fbd5a03 commit aac474a
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 8 deletions.
16 changes: 10 additions & 6 deletions hfc/fabric/channel/channel.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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']:
Expand All @@ -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']

Expand Down
6 changes: 4 additions & 2 deletions hfc/fabric/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand Down
1 change: 1 addition & 0 deletions test/fixtures/peer-base.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions test/fixtures/peer-mutual-tls.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit aac474a

Please sign in to comment.