Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added deocde flag to get_channel_config_with_orderer #105

Merged
merged 2 commits into from
Aug 25, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When decode==False, do we still needs to run the decode(...)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in this case, it seems like we do, since after that it checks whether the correct block was fetched and fetches another one if needed.

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