Skip to content

Commit ac0fea3

Browse files
Added deocde flag to get_channel_config_with_orderer (#105)
* 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]>
1 parent cfc3d8b commit ac0fea3

File tree

4 files changed

+16
-8
lines changed

4 files changed

+16
-8
lines changed

hfc/fabric/channel/channel.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -929,7 +929,7 @@ def get_channel_config(self, tx_context, peers,
929929
tx_context.tx_prop_req = request
930930
return self.send_tx_proposal(tx_context, peers)
931931

932-
async def get_channel_config_with_orderer(self, tx_context, orderer):
932+
async def get_channel_config_with_orderer(self, tx_context, orderer, decode=True):
933933
"""Query the current config block for this channel
934934
935935
:param tx_context: tx_context instance
@@ -974,9 +974,8 @@ async def get_channel_config_with_orderer(self, tx_context, orderer):
974974
block = v.block
975975
break
976976

977-
block = BlockDecoder().decode(block.SerializeToString())
978-
979-
last_config = block['metadata']['metadata'][common_pb2.LAST_CONFIG]
977+
decoded_block = BlockDecoder().decode(block.SerializeToString())
978+
last_config = decoded_block['metadata']['metadata'][common_pb2.LAST_CONFIG]
980979

981980
# if nor first block
982981
if 'index' in last_config['value']:
@@ -996,9 +995,14 @@ async def get_channel_config_with_orderer(self, tx_context, orderer):
996995
block = v.block
997996
break
998997

999-
block = BlockDecoder().decode(block.SerializeToString())
998+
if not decode:
999+
return block.SerializeToString()
1000+
decoded_block = BlockDecoder().decode(block.SerializeToString())
1001+
1002+
if not decode:
1003+
return block.SerializeToString()
10001004

1001-
envelope = block['data']['data'][0]
1005+
envelope = decoded_block['data']['data'][0]
10021006
payload = envelope['payload']
10031007
channel_header = payload['header']['channel_header']
10041008

hfc/fabric/client.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -761,7 +761,8 @@ async def get_channel_config(self, requestor, channel_name,
761761

762762
async def get_channel_config_with_orderer(self, requestor,
763763
channel_name,
764-
orderer=None):
764+
orderer=None,
765+
decode=True):
765766
"""
766767
Get configuration block for the channel with the orderer
767768
@@ -788,7 +789,8 @@ async def get_channel_config_with_orderer(self, requestor,
788789

789790
config_envelope = await channel.get_channel_config_with_orderer(
790791
tx_context,
791-
target_orderer)
792+
target_orderer,
793+
decode)
792794

793795
return config_envelope
794796

test/fixtures/peer-base.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ services:
1212
peer-base:
1313
image: hyperledger/fabric-peer:${HLF_VERSION}
1414
environment:
15+
- CORE_CHAINCODE_BUILDER=hyperledger/fabric-ccenv:1.4.6
1516
- GODEBUG=netdns=go+1
1617
- FABRIC_LOGGING_SPEC=debug
1718
#- CORE_PEER_ID=peer0

test/fixtures/peer-mutual-tls.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ services:
1212
peer-base:
1313
image: hyperledger/fabric-peer:${HLF_VERSION}
1414
environment:
15+
- CORE_CHAINCODE_BUILDER=hyperledger/fabric-ccenv:1.4.6
1516
- GODEBUG=netdns=go+1
1617
- FABRIC_LOGGING_SPEC=debug
1718
#- CORE_PEER_ID=peer0

0 commit comments

Comments
 (0)