hfc.fabric.block_decoder

Module Contents

Classes

BlockDecoder()

An object of a fully decoded protobuf message “Block”

FilteredBlockDecoder()

An object of a fully decoded protobuf message “FilteredBlock”

HeaderType()

HeaderType class having decodePayload and convertToString methods

Functions

decode_block_header(proto_block_header)

Decodes the header of Block

decode_block_data(proto_block_data, not_proto=False)

Decodes the data of Block.

decode_block_metadata(proto_block_metadata)

Decodes block metadata from block

decode_block_data_envelope(proto_envelope)

Decodes the envelope contents of Block

decode_header(proto_header)

Decodes the Payload header in envelope

decode_channel_header(header_bytes)

Decodes channel header for Payload channel header

timestamp_to_date(timestamp)

Converts timestamp to current date

decode_version(version_long)

Takes version proto object and returns version

decode_signature_header(signature_header_bytes)

Decode signature header

decode_identity(id_bytes)

Decodes identity

decode_metadata_signatures(metadata_bytes)

Decodes metadata signature from bytes

decode_metadata_value_signatures(proto_meta_signatures)

Decodes all signatures in metadata values

decode_last_config_sequence_number(metadata_bytes)

Decodes last configuration and index for sequence number

decode_transaction_filter(metadata_bytes)

Decodes transaction filter from metadata bytes

decode_endorser_transaction(trans_bytes)

Decodes

decode_config_envelope(config_envelope_bytes)

Decodes configuration envelope

decode_config(proto_config)

Decodes configuration from config envelope

decode_config_update_envelope(config_update_envelope_bytes)

Decode config update envelope

decode_config_update(config_update_bytes)

Decodes update bytes in configuration

decode_config_groups(config_group_map)

Decodes configuration groups inside ConfigGroup

decode_config_group(proto_config_group)

Decodes configuration group from config protos

decode_config_values(config_value_map)

Decodes configuration values inside each configuration key

decode_config_value(proto_config_value, key)

Decodes ConfigValue from map with a given key

decode_config_policies(config_policy_map)

Decodes list of configuration policies

decode_config_policy(proto_config_policy)

Decodes config policy based on type of policy

decode_implicit_meta_policy(implicit_meta_policy_bytes)

Decodes implicit meta policy in a policy

decode_signature_policy_envelope(signature_policy_envelope_bytes)

Decodes signature policy envelope bytes

decode_signature_policy(proto_signature_policy)

Decodes signature policy based on field

decode_MSP_principal(proto_msp_principal)

Decodes MSP Principal

decode_config_signature(proto_configSignature)

Decodes Configuration Signature

decode_fabric_MSP_config(msp_config_bytes)

Decodes Fabric MSP Configuration

decode_fabric_OU_identifier(FabricOUIdentifier)

Decodes Fabric OU Identifier

decode_fabric_Nodes_OUs(proto_node_organizational_units)

Decodes Fabric Node OUs

to_PEM_certs(buffer_array_in)

Decodes String buffer input to PEM Certs

decode_signing_identity_info(signing_identity_info_bytes)

Decodes Signing identity information from MSP Configuration

decode_key_info(key_info_bytes)

Decodes Key Infor in MSP Configuration

decode_crypto_config(crypto_config_bytes)

Decodes Crypto Config in MSP Configuration

decode_chaincode_action_payload(payload_bytes)

Decodes chaincode action payload from ChaincodeAction

decode_chaincode_proposal_payload(chaincode_proposal_payload_bytes)

Decodes chaincode proposal payload from ChaincodeProposal

decode_chaincode_endorsed_action(proto_chaincode_endorsed_action)

Decodes chaincode endorsed action

decode_endorsement(proto_endorsement)

Decodes each endorsement

decode_proposal_response_payload(proposal_response_payload_bytes)

Decodes response payload in the proposal

decode_chaincode_action(action_bytes)

Decodes chaincode actions

decode_chaincode_events(event_bytes)

Decodes events in the chaincode

decode_chaincode_id(proto_chaincode_id)

Decodes chaincode ID information

decode_readwrite_sets(rw_sets_bytes)

Decodes read write sets from a given TxReadWriteSet

decode_kv_rw_set(kv_bytes)

Decodes Key Value Read Write Set from KV Bytes

decode_kv_read(proto_kv_read)

Decodes Key Value Read

decode_range_query_info(proto_range_query_info)

Decodes range query information from KV RW sets.

decode_kv_write(proto_kv_write)

Decodes key value write instance

decode_response(proto_response)

Decodes response containing status, message and payload

decode_fabric_peers_info(peers_info_bytes)

Decodes Fabric Peers Information

decode_fabric_endpoints(endpoints)

Decodes Fabric Endpoints

hfc.fabric.block_decoder._logger
class hfc.fabric.block_decoder.BlockDecoder

Bases: object

An object of a fully decoded protobuf message “Block”

static decode(block_bytes)

Constructs a JSON Object containing all decoded values from protobuf encoded Block bytes.

Parameters

block_bytes (bytes) – Block instance

Returns

Dictionary containing decoded Block instance.

static decode_transaction(processed_tx_bytes)

Decodes a transaction proto and constructs a deserialized object

Parameters

processed_tx_bytes – Binary content of tx

Returns

Dictionary containing tx block information

Raises

ValueError – If data is not passed to the method

class hfc.fabric.block_decoder.FilteredBlockDecoder

Bases: object

An object of a fully decoded protobuf message “FilteredBlock”

static decode(block_bytes)

Constructs a JSON Object containing all decoded values from protobuf encoded FilteredBlock bytes.

Parameters

block_bytes (bytes) – FilteredBlock instance

Returns

Dictionary containing decoded Filtered Block instance.

hfc.fabric.block_decoder.tx_validation_code
hfc.fabric.block_decoder.type_as_string
hfc.fabric.block_decoder.implicit_metapolicy_rule = ['ANY', 'ALL', 'MAJORITY']
hfc.fabric.block_decoder.policy_policy_type = ['UNKNOWN', 'SIGNATURE', 'MSP', 'IMPLICIT_META']
class hfc.fabric.block_decoder.HeaderType

Bases: object

HeaderType class having decodePayload and convertToString methods

static convert_to_string(type_value)
static decode_payload_based_on_type(proto_data, type_value)
hfc.fabric.block_decoder.decode_block_header(proto_block_header)

Decodes the header of Block

Parameters

proto_block_header (str) – Block Header proto

Returns

Decoded BlockHeader inside Block instance.

hfc.fabric.block_decoder.decode_block_data(proto_block_data, not_proto=False)

Decodes the data of Block.

Parameters
  • proto_block_data (str) – Block Data proto.

  • not_proto (bool) – Boolean for if proto.

Returns

deserialized block_data (Default value = False)

hfc.fabric.block_decoder.decode_block_metadata(proto_block_metadata)

Decodes block metadata from block

Parameters

proto_block_metadata (bytes) – Block metadata proto content

Returns

deserialized metadata contents

hfc.fabric.block_decoder.decode_block_data_envelope(proto_envelope)

Decodes the envelope contents of Block

Parameters

proto_envelope (str) – Envelope proto

Returns

deserialized block envelope

hfc.fabric.block_decoder.decode_header(proto_header)

Decodes the Payload header in envelope

Parameters

proto_header (str) – Envelope Payload

Returns

deserialized envelope header

hfc.fabric.block_decoder.decode_channel_header(header_bytes)

Decodes channel header for Payload channel header

Parameters

header_bytes (str) – Bytes channel header

Returns

deserialized payload channel_header

hfc.fabric.block_decoder.timestamp_to_date(timestamp)

Converts timestamp to current date

Parameters

timestamp – Timestamp value

Returns

String formatted date in %Y-%m-%d %H:%M:%S

hfc.fabric.block_decoder.decode_version(version_long)

Takes version proto object and returns version

Parameters

version_long – version proto object

Returns

integer value of version_long

hfc.fabric.block_decoder.decode_signature_header(signature_header_bytes)

Decode signature header

Parameters

signature_header_bytes – signature header bytes

Returns

deserialized signature_header

hfc.fabric.block_decoder.decode_identity(id_bytes)

Decodes identity

Parameters

id_bytes – byte of identity

Returns

deserialized identity

hfc.fabric.block_decoder.decode_metadata_signatures(metadata_bytes)

Decodes metadata signature from bytes

Parameters

metadata_bytes (str) – Metadata object proto

Returns

deserialized Metadata blocks

hfc.fabric.block_decoder.decode_metadata_value_signatures(proto_meta_signatures)

Decodes all signatures in metadata values

Parameters

proto_meta_signatures (list(str) – List of value objects

Returns

deserialized list of signatures from metadata values

hfc.fabric.block_decoder.decode_last_config_sequence_number(metadata_bytes)

Decodes last configuration and index for sequence number

Parameters

metadata_bytes (str) – encoded content for sequence number

Returns

deserialized dictionary of config sequence number

hfc.fabric.block_decoder.decode_transaction_filter(metadata_bytes)

Decodes transaction filter from metadata bytes

Parameters

metadata_bytes (str) – Encoded list of transaction filters

Returns

decoded transaction_filter list

hfc.fabric.block_decoder.decode_endorser_transaction(trans_bytes)

Decodes

Parameters

trans_bytes – Serialized endorser transaction bytes

Returns

deserialized dictionary of endorser transaction data

hfc.fabric.block_decoder.decode_config_envelope(config_envelope_bytes)

Decodes configuration envelope

Parameters

config_envelope_bytes – byte of config envelope

Returns

deserialized config envelope

hfc.fabric.block_decoder.decode_config(proto_config)

Decodes configuration from config envelope

Parameters

proto_config (bytes) – Config value

Returns

deserialized config

hfc.fabric.block_decoder.decode_config_update_envelope(config_update_envelope_bytes)

Decode config update envelope

Parameters

config_update_envelope_bytes (str) – Bytes of update envelope

Returns

deserialized config update envelope signatures

hfc.fabric.block_decoder.decode_config_update(config_update_bytes)

Decodes update bytes in configuration

Parameters

config_update_bytes (str) – Bytes

Returns

deserialized configuration update

hfc.fabric.block_decoder.decode_config_groups(config_group_map)

Decodes configuration groups inside ConfigGroup

Parameters

config_group_map (str) – Serialized ConfigGroup.groups object

Returns

map of configuration groups.

hfc.fabric.block_decoder.decode_config_group(proto_config_group)

Decodes configuration group from config protos

Parameters

proto_config_group (str) – serialized ConfigGroup() object

Returns

deserialized config_groups dictionary

hfc.fabric.block_decoder.decode_config_values(config_value_map)

Decodes configuration values inside each configuration key

Parameters

config_value_map (str) – Serialized values map for each config key

Returns

map of configuration values for each key

hfc.fabric.block_decoder.decode_config_value(proto_config_value, key)

Decodes ConfigValue from map with a given key

Parameters
  • proto_config_value (str) – A bytes string of config_value

  • key (str) – Map key for the configuration value

Returns

Dictionary of configuration value deserialized

hfc.fabric.block_decoder.decode_config_policies(config_policy_map)

Decodes list of configuration policies

Parameters

config_policy_map (str) – Serialized list of configuration policies

Returns

deserialized map of config policies.

hfc.fabric.block_decoder.decode_config_policy(proto_config_policy)

Decodes config policy based on type of policy

Parameters

proto_config_policy – Configuration policy bytes

Returns

deserialized config_policy based on policy type.

hfc.fabric.block_decoder.decode_implicit_meta_policy(implicit_meta_policy_bytes)

Decodes implicit meta policy in a policy

Parameters

implicit_meta_policy_bytes (str) – Bytes of implicit meta policy

Returns

deserialized implicit_meta_policy value.

hfc.fabric.block_decoder.decode_signature_policy_envelope(signature_policy_envelope_bytes)

Decodes signature policy envelope bytes

Parameters

signature_policy_envelope_bytes (str) – Serialized signature envelope

Returns

deserialized signature policy envelope contents.

hfc.fabric.block_decoder.decode_signature_policy(proto_signature_policy)

Decodes signature policy based on field

Parameters

proto_signature_policy – Object of SignaturePolicy()

Returns

deserialized signature policy after decoding based on field.

hfc.fabric.block_decoder.decode_MSP_principal(proto_msp_principal)

Decodes MSP Principal

Parameters

proto_msp_principal (str) – Bytes for MSP Principals

Returns

deserialized MSP Principal based on classification.

hfc.fabric.block_decoder.decode_config_signature(proto_configSignature)

Decodes Configuration Signature

Parameters

proto_configSignature (str) – ConfigSignature() object

Returns

deserialized config signature after header decode.

hfc.fabric.block_decoder.decode_fabric_MSP_config(msp_config_bytes)

Decodes Fabric MSP Configuration

Parameters

msp_config_bytes (str) – Serialized configuration for MSP

Returns

Deserialized MSP configuration and certs.

hfc.fabric.block_decoder.decode_fabric_OU_identifier(FabricOUIdentifier)

Decodes Fabric OU Identifier

Parameters

FabricOUIdentifier (str) – OU Identifier

Returns

OU Identifier object.

hfc.fabric.block_decoder.decode_fabric_Nodes_OUs(proto_node_organizational_units)

Decodes Fabric Node OUs

Parameters

proto_node_organizational_units (str) – OUs

Returns

deserialized list of OU Identifier objects.

hfc.fabric.block_decoder.to_PEM_certs(buffer_array_in)

Decodes String buffer input to PEM Certs

Parameters

buffer_array_in (str) – certificate contents buffer

Returns

Concats buffer contents and returns certs

hfc.fabric.block_decoder.decode_signing_identity_info(signing_identity_info_bytes)

Decodes Signing identity information from MSP Configuration

Parameters

signing_identity_info_bytes (str) – Byte string of the identity info

Returns

deserialized signing identity information.

hfc.fabric.block_decoder.decode_key_info(key_info_bytes)

Decodes Key Infor in MSP Configuration

Parameters

key_info_bytes (str) – Byte information containing KeyInfo

Returns

deserialized key information.

hfc.fabric.block_decoder.decode_crypto_config(crypto_config_bytes)

Decodes Crypto Config in MSP Configuration

Parameters

crypto_config_bytes (str) – Byte information of FabricCyptoConfig

Returns

deserialized key information.

hfc.fabric.block_decoder.decode_chaincode_action_payload(payload_bytes)

Decodes chaincode action payload from ChaincodeAction

Parameters

payload_bytes (str) – Bytes buffer of the payload

Returns

deserialized payload information and action.

hfc.fabric.block_decoder.decode_chaincode_proposal_payload(chaincode_proposal_payload_bytes)

Decodes chaincode proposal payload from ChaincodeProposal

Parameters

chaincode_proposal_payload_bytes (str) – Bytes of chaincode proposal

Returns

deserialized chaincode proposal payload information

hfc.fabric.block_decoder.decode_chaincode_endorsed_action(proto_chaincode_endorsed_action)

Decodes chaincode endorsed action

Parameters

proto_chaincode_endorsed_action – Object containing endorsements

Returns

deserialized chaincode endorsement action.

hfc.fabric.block_decoder.decode_endorsement(proto_endorsement)

Decodes each endorsement

Parameters

proto_endorsement – Object of endorsed content containing endorser & related signature

Returns

deserialized endorsement content

hfc.fabric.block_decoder.decode_proposal_response_payload(proposal_response_payload_bytes)

Decodes response payload in the proposal

Parameters

proposal_response_payload_bytes – Byte string of response payload

Returns

deserialized proposal response payload.

hfc.fabric.block_decoder.decode_chaincode_action(action_bytes)

Decodes chaincode actions

Parameters

action_bytes (str) – Byte buffer of the chaincode action

Returns

deserialized chaincode action of results, events and response

hfc.fabric.block_decoder.decode_chaincode_events(event_bytes)

Decodes events in the chaincode

Parameters

event_bytes (str) – Byte buffer of event content

Returns

deserialized event contents.

hfc.fabric.block_decoder.decode_chaincode_id(proto_chaincode_id)

Decodes chaincode ID information

Parameters

proto_chaincode_id – Object containing chaincode details

Returns

deserialized chaincode ID with path, name and version.

hfc.fabric.block_decoder.decode_readwrite_sets(rw_sets_bytes)

Decodes read write sets from a given TxReadWriteSet

Parameters

rw_sets_bytes (str) – Byte buffer of the TxReadWriteSet

Returns

deserialized transaction read write set contents.

hfc.fabric.block_decoder.decode_kv_rw_set(kv_bytes)

Decodes Key Value Read Write Set from KV Bytes

Parameters

kv_bytes (str) – Buffer of key value bytes

Returns

deserialized key value read write set of reads, writes and range queries information.

hfc.fabric.block_decoder.decode_kv_read(proto_kv_read)

Decodes Key Value Read

Parameters

proto_kv_read – Object of the key value with read contents

Returns

deserialized key value read contents with block num and tx_num

hfc.fabric.block_decoder.decode_range_query_info(proto_range_query_info)

Decodes range query information from KV RW sets.

Parameters

proto_range_query_info – Object of key value read write range queries

Returns

deserialized range query information with merkle hashes.

hfc.fabric.block_decoder.decode_kv_write(proto_kv_write)

Decodes key value write instance

Parameters

proto_kv_write – Object containing key value writes

Returns

deserialized key value write contents and values.

hfc.fabric.block_decoder.decode_response(proto_response)

Decodes response containing status, message and payload

Parameters

proto_response – Object containing proto responses

Returns

deserialized response from protobuf objects

hfc.fabric.block_decoder.decode_fabric_peers_info(peers_info_bytes)

Decodes Fabric Peers Information

Parameters

peers_info_bytes (str) – Serialized information about Peer

Returns

Deserialized Peers information and certs.

hfc.fabric.block_decoder.decode_fabric_endpoints(endpoints)

Decodes Fabric Endpoints

Parameters

endpoints (str) – Fabric Endpoints

Returns

Deserialized endpoints.