hfc.fabric.channel.channel
¶
Module Contents¶
Functions¶
|
Create system channel instance |
|
Create application channel instance |
-
hfc.fabric.channel.channel.
SYSTEM_CHANNEL_NAME
= testchainid¶
-
hfc.fabric.channel.channel.
_logger
¶
-
class
hfc.fabric.channel.channel.
Channel
(name, client)¶ Bases:
object
The class represents the channel.
This is a client-side-only call. To create a new channel in the fabric call client._create_or_update_channel().
-
add_orderer
(self, orderer)¶ Add orderer endpoint to a channel object.
A channel instance may choose to use a single orderer node, which will broadcast requests to the rest of the orderer network. Or if the application does not trust the orderer nodes, it can choose to use more than one by adding them to the channel instance. And all APIs concerning the orderer will broadcast to all _orderers simultaneously.
- Parameters
orderer – an instance of the Orderer class
- Returns
-
remove_orderer
(self, orderer)¶ Remove orderer endpoint from a channel object.
- Parameters
orderer – an instance of the Orderer class
- Returns
-
add_peer
(self, peer)¶ Add peer endpoint to a chain object.
- Parameters
peer – an instance of the Peer class
- Returns
-
remove_peer
(self, peer)¶ Remove peer endpoint from a channel object.
- Parameters
peer – an instance of the Peer class
- Returns
-
property
orderers
(self)¶ Get _orderers of a channel.
- Returns
The orderer list on the channel
-
property
peers
(self)¶ Get peers of a channel.
- Returns
The peer list on the chain
-
property
is_dev_mode
(self)¶ Get is_dev_mode
- Returns
is_dev_mode
-
_get_latest_block
(self, tx_context, orderer)¶ Get latest block from orderer.
- Parameters
tx_context – a tx_context instance
orderer – a orderer instance
- Returns
-
_get_random_orderer
(self)¶
-
property
name
(self)¶ Get channel name.
- Returns
channel name
-
state_store
(self)¶ Get the key val store instance of the instantiating client. Get the KeyValueStore implementation (if any) that is currently associated with this channel :return: the current KeyValueStore associated with this channel / client.
-
_validate_state
(self)¶ Validate channel state.
- Raises
ValueError –
-
property
is_sys_chan
(self)¶ Get if system channel
-
_validate_peer
(self, peer)¶ Validate peer
- Parameters
peer – peer
- Raises
ValueError –
-
_validate_peers
(self, peers)¶ Validate peer set
- Parameters
peers – peers
- Raises
ValueError –
-
send_install_proposal
(self, tx_context, peers=None)¶ Send install chaincode proposal
- Parameters
install_proposal_req – install proposal request
targets – a set of peer to send
tx_context – a tx_context instance
peers – peers (Default value = None)
- Returns
a set of proposal response
-
_build_channel_header
(type, tx_id, channel_id, timestamp, epoch=0, extension=None)¶ Build channel.
- Parameters
extension – extension (Default value = None)
timestamp – timestamp
channel_id – channel id
tx_id – transaction id
type – type
epoch – epoch
- Returns
common_proto.Header instance (Default value = 0)
-
is_readonly
(self)¶ Check the channel if read-only
Get the channel status to see if the underlying channel has been terminated, making it a read-only channel, where information (transactions and state_store) can be queried but no new transactions can be submitted.
- Returns
True if the channel is read-only, False otherwise.
-
join_channel
(self, request)¶ To join the peer to a channel.
- Parameters
request – request
- Returns
A coroutine to handle thanks to asyncio with await asyncio.gather(*responses)
-
send_instantiate_proposal
(self, tx_context, peers)¶ Send instantiate chaincode proposal.
- Parameters
tx_context – transaction context
peers – peers to send this proposal
- Returns
True in success False in failure
-
send_upgrade_proposal
(self, tx_context, peers)¶ Upgrade the chaincode.
- Parameters
tx_context – transaction context
peers – peers to send this proposal
- Returns
True in success and False in failure
-
_build_principal
(self, identity)¶
-
_get_policy
(self, policy)¶
-
_check_policy
(self, policy)¶
-
_build_policy
(self, policy, msps=None, returnProto=False)¶
-
_send_cc_proposal
(self, tx_context, command, peers)¶
-
send_tx_proposal
(self, tx_context, peers)¶ Invoke the chaincode
Send a transaction proposal to one or more endorser without creating a channel. :param tx_context: transaction context :param peers: the pees to send this proposal
if it is None the channel peers list will be used.
channel_id: channel id client: client context :return: True in success or False in failure.
-
static
_send_tx_proposal
(channel_id, tx_context, peers)¶
-
query_instantiated_chaincodes
(self, tx_context, peers, transient_map=None)¶ - Parameters
tx_context – tx_context instance
peers – peers in the channel
transient_map – transient map
- Returns
chain code response (Default value = None)
-
query_transaction
(self, tx_context, peers, tx_id, transient_map=None)¶ Queries the ledger for Transaction by transaction ID.
- Parameters
tx_context – tx_context instance
peers – peers in the channel
tx_id – transaction ID (string)
transient_map – transient map
- Returns
chain code response (Default value = None)
-
get_block_between
(self, tx_context, orderer, start, end)¶ - Parameters
tx_context – tx_context instance
orderer – orderer instance
start – id of block to start query for
end – id of block to end query for
- Returns
block(s)
-
query_block
(self, tx_context, peers, block_number, transient_map=None)¶ Queries the ledger for Block by block number.
- Parameters
tx_context – tx_context instance
peers – peers in the channel
block_number – block to query for
transient_map – transient map (Default value = None)
- Returns
class BlockDecoder
-
query_block_by_hash
(self, tx_context, peers, block_hash, transient_map=None)¶ - Parameters
tx_context – tx_context instance
peers – peers in the channel
block_hash – block to query for
transient_map – transient map (Default value = None)
- Returns
class ChaincodeQueryResponse
-
query_block_by_txid
(self, tx_context, peers, tx_id, transient_map=None)¶ - Parameters
tx_context – tx_context instance
peers – peers in the channel
tx_id – transaction id
transient_map – transient map (Default value = None)
- Returns
class ChaincodeQueryResponse
-
query_info
(self, tx_context, peers, transient_map=None)¶ Query the information of channel
Queries for various useful information on the state of the channel (height, known peers).
- Parameters
tx_context – tx_context instance
peers – peers in the channel
transient_map – (Default value = None)
- Returns
class ChaincodeQueryResponse channelinfo with height, currently the only useful information.
-
get_channel_config
(self, tx_context, peers, transient_map=None)¶ Query the current config block for this channel
- Parameters
tx_context – tx_context instance
peers – peers in the channel
transient_map – (Default value = None)
- Returns
class ChaincodeQueryResponse channelinfo with height, currently the only useful information.
-
async
get_channel_config_with_orderer
(self, tx_context, orderer)¶ Query the current config block for this channel
- Parameters
tx_context – tx_context instance
peers – peers in the channel
:return:class ChaincodeQueryResponse channelinfo with height, currently the only useful information.
-
_discovery
(self, requestor, target, local=False, config=False, interests=None)¶ - Send a request from a target peer to discover information about the
network
- Parameters
requestor (instance) – a user to make the request
target (instance) – target peer to send discovery request
local (bool) – include local endpoints in the query (Default value = False)
config (bool) – include channel configuration in the query (Default value = False)
interests (list) – interests about an endorsement for cc (Default value = None)
- Returns
Response from Discovery Service
-
_build_proto_cc_interest
(self, interest)¶ Use a list of DiscoveryChaincodeCall to build an interest.
- Parameters
interest –
- Returns
-
newChannelEventHub
(self, peer, requestor)¶
-
getChannelEventHubsForOrg
(self, requestor, mspid=None)¶
-
-
hfc.fabric.channel.channel.
create_system_channel
(client, name=SYSTEM_CHANNEL_NAME)¶ Create system channel instance
- Parameters
client – client instance
name – system channel name (Default value = SYSTEM_CHANNEL_NAME)
- Returns
return system channel instance
-
hfc.fabric.channel.channel.
create_app_channel
(client, name)¶ Create application channel instance
- Parameters
client – client instance
name – return application channel instance
- Returns
system channel instance