hfc.util.utils¶
Module Contents¶
Classes¶
Functions¶
|
|
Create serialized identity from user. |
|
|
This function will build the common header. |
|
Build channel header. |
|
Check if signatures are already in protobuf format. |
Get current timestamp. |
|
|
Extracts the protobuf ‘ConfigUpdate’ object out ouf the ‘ConfigEnvelope’. |
|
Create an chaincode transaction proposal |
|
Sign a proposal |
|
Send transaction proposal |
|
Send a transaction to the chain’s orderer service (one or more |
|
Sign a transaction payload |
|
Check the endorsements from peers |
|
Send install chaincode proposal |
|
|
|
Package all chaincode env into a tar.gz file |
|
|
|
-
hfc.util.utils.CC_INSTALL= install¶
-
hfc.util.utils.CC_TYPE_GOLANG= GOLANG¶
-
hfc.util.utils._logger¶
-
hfc.util.utils.proto_str(x)¶
-
hfc.util.utils.proto_b¶
-
hfc.util.utils.create_serialized_identity(user)¶ Create serialized identity from user.
- Parameters
user (user object) – The user object that should be serialized.
- Returns
Protobuf SerializedIdentity of the given user object.
- Return type
serialized_identity
-
hfc.util.utils.build_header(creator, channel_header, nonce)¶ This function will build the common header.
- Parameters
creator (protobuf SerializedIdentity) – Serialized identity of the creator.
channel_header (protobuf ChannelHeader) – ChannelHeader
nonce (str) – Nonce that has been used for the tx_id.
- Returns
Returns created protobuf common header.
- Return type
header
-
hfc.util.utils.build_channel_header(type, tx_id, channel_id, timestamp, epoch=0, extension=None, tls_cert_hash=None)¶ Build channel header.
- Parameters
type (common_pb2.HeaderType) – type
tx_id (str) – transaction id
channel_id (str) – channel id
timestamp (grpc.timestamp) – timestamp
epoch (int) – epoch (Default value = 0)
extension – extension (Default value = None)
tls_cert_hash – (Default value = None)
- Returns
common_proto.Header instance
-
hfc.util.utils.string_to_signature(string_signatures)¶ Check if signatures are already in protobuf format.
- Parameters
string_signatures (list) – An list of protobuf ConfigSignatures either represented as or serialized as byte strings.
- Returns
List of protobuf ConfigSignatures.
- Return type
list
-
hfc.util.utils.current_timestamp()¶ Get current timestamp.
- Returns
Current timestamp.
-
hfc.util.utils.extract_channel_config(configtx_proto_envelope)¶ Extracts the protobuf ‘ConfigUpdate’ object out ouf the ‘ConfigEnvelope’.
- Parameters
configtx_proto_envelope (common_pb2.Envelope) – The encoded bytes of the ConfigEnvelope protofbuf.
- Returns
(config_update) The encoded bytes of the ConfigUpdate protobuf, ready to be signed
- Return type
configtx_pb2.ConfigUpadeEnvelope.config_update
- Raises
ValueError – If there is an error in protobuf_decode due to a wrong or not valid profobuf file a ValueError is raised.
-
hfc.util.utils.build_cc_proposal(cci_spec, header, transient_map)¶ Create an chaincode transaction proposal
- Parameters
transient_map – transient data map
cci_spec – The spec
header – header of the proposal
- Returns
The created proposal
-
hfc.util.utils.sign_proposal(tx_context, proposal)¶ Sign a proposal
- Parameters
tx_context – transaction context
proposal – proposal to sign on
- Returns
Signed proposal
-
hfc.util.utils.send_transaction_proposal(proposal, tx_context, peers)¶ Send transaction proposal
- Parameters
header – header
tx_context – transaction context
proposal – transaction proposal
peers – peers
- Returns
a list containing all the proposal response
-
hfc.util.utils.send_transaction(orderers, tran_req, tx_context)¶ Send a transaction to the chain’s orderer service (one or more orderer endpoints) for consensus and committing to the ledger.
This call is asynchronous and the successful transaction commit is notified via a BLOCK or CHAINCODE event. This method must provide a mechanism for applications to attach event listeners to handle ‘transaction submitted’, ‘transaction complete’ and ‘error’ events.
- Parameters
tx_context – transaction context
orderers – orderers
tran_req (TransactionRequest) – The transaction object
- Returns
(EventEmitter) an handle to allow the application to attach event handlers on ‘submitted’, ‘complete’, and ‘error’.
- Return type
EventEmitter
-
hfc.util.utils.sign_tran_payload(tx_context, tran_payload_bytes)¶ Sign a transaction payload
- Parameters
signing_identity – id to sign with
tran_payload – transaction payload to sign on
tx_context –
tran_payload_bytes –
- Returns
Envelope
-
hfc.util.utils.build_tx_req(ProposalResponses)¶ Check the endorsements from peers
- Parameters
reponses – ProposalResponse from endorsers
ProposalResponses –
- Returns
an instance of TXRequest
-
hfc.util.utils.send_install_proposal(tx_context, peers)¶ Send install chaincode proposal
- Parameters
tx_context – transaction context
peers – peers to install chaincode
- Returns
a set of proposal response
-
hfc.util.utils.zeroTarInfo(tarinfo)¶
-
class
hfc.util.utils.zeroTimeContextManager¶ Bases:
object-
__enter__(self)¶
-
__exit__(self, type, value, traceback)¶
-
-
hfc.util.utils.package_chaincode(cc_path, cc_type=CC_TYPE_GOLANG)¶ Package all chaincode env into a tar.gz file
- Parameters
cc_path – path to the chaincode
cc_type – chaincode type (Default value = CC_TYPE_GOLANG)
- Returns
The chaincode pkg path or None
-
hfc.util.utils.pem_to_der(pem)¶
-
async
hfc.util.utils.stream_envelope(envelope)¶