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)[source]

start/stop ledger_subsystem on the bbc_core (maybe used by a system administrator)

Parameters:enable – True->start, False->stop
Returns:
receiver_loop()[source]
register_asset_group(domain_id, asset_group_id, storage_type=1, storage_path=None, advertise_in_domain0=False)[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
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:
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:

send_domain_ping(domain_id, ipv4, ipv6, port)[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
Returns:
sendback_denial_of_sign(asset_group_id, dst, reason_text)[source]

Send back the denial of sign the transaction

Parameters:
  • asset_group_id
  • dst
  • reason_text
Returns:

sendback_signature(asset_group_id, dst, ref_index, sig)[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
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:
set_domain_static_node(domain_id, node_id, ipv4, ipv6, port)[source]

Set static node to the core node (maybe used by a system administrator)

Parameters:
  • domain_id
  • node_id
  • ipv4
  • ipv6
  • port
Returns:

set_user_id(identifier)[source]

Set user_id of the object

Parameters:identifier
Returns:
start_receiver_loop()[source]
unregister_from_core()[source]

Unregister and disconnect from the core node

Returns:
verify_in_ledger_subsystem(asset_group_id, transaction_id)[source]

Verify transaction_id in the ledger_subsystem

Parameters:
  • asset_group_id
  • transaction_id
Returns:

class bbc_app.Callback(log=None)[source]

Bases: object

Set of callback functions for processing received message

dispatch(dat, payload_type)[source]
proc_cmd_sign_request(dat)[source]
proc_resp_asset_group_setup(dat)[source]
proc_resp_cross_ref(dat)[source]
proc_resp_domain_setup(dat)[source]
proc_resp_gather_signature(dat)[source]
proc_resp_get_config(dat)[source]
proc_resp_get_domainlist(dat)[source]

Return domain_ids

Parameters:dat
Returns:list of domain_id
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)
proc_resp_insert(dat)[source]
proc_resp_ledger_subsystem(dat)[source]
proc_resp_register_hash(dat)[source]
proc_resp_search_asset(dat)[source]
proc_resp_search_transaction(dat)[source]
proc_resp_set_peer(dat)[source]
proc_resp_sign_request(dat)[source]
proc_resp_verify_hash(dat)[source]
proc_user_message(dat)[source]
set_logger(log)[source]
synchronize(timeout=None)[source]

Wait for receiving message

Parameters:timeout – timeout second for waiting
Returns:
bbc_app.get_id_from_mappings(name, asset_group_id)[source]
bbc_app.remove_id_mappings(name, asset_group_id)[source]
bbc_app.store_id_mappings(name, asset_group_id, transaction_id=None, asset_ids=None)[source]