bbc_app module¶
Copyright (c) 2017 beyond-blockchain.org.
Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
BBcAppClient ([host, port, logname, loglevel]) |
-
class
bbc_app.
BBcAppClient
(host='127.0.0.1', port=9000, logname='-', loglevel='none')[source]¶ Bases:
object
-
domain_setup
(domain_id, module_name=None)[source]¶ Set up domain with the specified network module (maybe used by a system administrator)
Parameters: - domain_id –
- module_name –
- storage_type – StorageType value
- storage_path –
Returns:
-
gather_signatures
(asset_group_id, tx_obj, reference_obj=None, destinations=None, asset_files=None)[source]¶ Request to gather signatures from the specified user_ids
Parameters: - asset_group_id –
- tx_obj –
- reference_obj – BBcReference object
- destinations – list of destination user_ids
- asset_files – dictionary of {asset_id: file_content}
Returns:
-
get_bbc_config
()[source]¶ Get config file of bbc_core (maybe used by a system administrator)
Returns:
-
get_cross_refs
(asset_group_id, number)[source]¶ Get cross_refs
Parameters: - asset_group_id –
- number –
Returns:
-
get_domain_list
()[source]¶ Get domain_id list in bbc_core (maybe used by a system administrator)
Returns:
-
get_domain_peerlist
(domain_id)[source]¶ Get peer list of the domain from the core node (maybe used by a system administrator)
Parameters: domain_id – Returns:
-
insert_transaction
(asset_group_id, tx_obj)[source]¶ Request to insert a legitimate transaction
Parameters: - asset_group_id –
- tx_obj – Transaction object (not deserialized one)
Returns:
-
make_message_structure
(asset_group_id, cmd)[source]¶ (internal use) make a base message structure for sending to the core node
Parameters: - asset_group_id –
- cmd –
Returns:
-
manipulate_ledger_subsystem
(enable=False, domain_id=None)[source]¶ start/stop ledger_subsystem on the bbc_core (maybe used by a system administrator)
Parameters: - enable – True->start, False->stop
- domain_id –
Returns:
-
ping_to_all_neighbors
(domain_id)[source]¶ Request bbc_core to send ping to all its neighbors :param domain_id: :return:
-
register_asset_group
(domain_id, asset_group_id, storage_type=1, storage_path=None, advertise_in_domain0=False, max_body_size=256)[source]¶ Register an asset_group in the core node (maybe used by a system administrator)
Parameters: - domain_id –
- asset_group_id –
- storage_type –
- storage_path –
- advertise_in_domain0 –
- max_body_size –
Returns:
-
register_in_ledger_subsystem
(asset_group_id, transaction_id)[source]¶ Register transaction_id in the ledger_subsystem
Parameters: - asset_group_id –
- transaction_id –
Returns:
-
register_to_core
()[source]¶ Register the client (user_id) to the core node. After that, the client can communicate with the core node
Returns:
-
request_insert_completion_notification
(asset_group_id, flag)[source]¶ Request notification when a transaction has been inserted (as a copy of transaction) :param asset_group_id: :param flag: :return:
-
search_asset
(asset_group_id, asset_id)[source]¶ Search request for the specified asset. This would return transaction_data (and asset_file file content)
Parameters: - asset_group_id –
- asset_id –
Returns:
-
search_transaction
(asset_group_id, transaction_id)[source]¶ Search request for transaction_data
Parameters: - asset_group_id –
- transaction_id –
Returns:
-
search_transaction_by_userid
(asset_group_id, user_id)[source]¶ Search request for transaction_data by user_id
Parameters: - asset_group_id –
- user_id – user_id of the asset owner
Returns: The transaction_data that includes asset with the specified user_id
-
send_domain_ping
(domain_id, ipv4=None, ipv6=None, port=6641)[source]¶ Send domain ping to notify the existence of the node (maybe used by a system administrator)
Parameters: - domain_id –
- ipv4 –
- ipv6 –
- port –
Returns:
-
send_message
(msg, asset_group_id, dst_user_id)[source]¶ Send peer-to-peer message to the specified user_id
Parameters: - msg –
- asset_group_id –
- dst_user_id –
Returns:
-
send_msg
(dat)[source]¶ (internal use) send the message to the core node
Parameters: dat – Return query_id or None:
-
sendback_denial_of_sign
(asset_group_id, dst, reason_text, query_id=None)[source]¶ Send back the denial of sign the transaction
Parameters: - asset_group_id –
- dst –
- reason_text –
- query_id –
Returns:
-
sendback_signature
(asset_group_id, dst, ref_index, sig, query_id=None)[source]¶ Send back the signed transaction to the source
Parameters: - asset_group_id –
- dst –
- ref_index – Which reference in transaction the signature is for
- sig –
- query_id –
Returns:
-
set_asset_group_id
(asset_group_id)[source]¶ Set asset_group_id (before register_to_core)
Parameters: asset_group_id – Returns:
-
set_callback
(callback_obj)[source]¶ Set callback object that implements message processing functions
Parameters: callback_obj – Returns:
-
-
class
bbc_app.
Callback
(log=None)[source]¶ Bases:
object
Set of callback functions for processing received message
-
proc_resp_get_peerlist
(dat)[source]¶ Return node info
Parameters: dat – Returns: list of node info (the first one is that of the connecting core)
-