bbc_app module — BBc1 0.7 documentation

# 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

> http://www.apache.org/licenses/LICENSE-2.0

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')

  Bases: `object`

  `domain_setup`(domain_id, module_name=None)

    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)

    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`()

    Get config file of bbc_core (maybe used by a system administrator)

    Returns: |

  `get_cross_refs`(asset_group_id, number)

    Get cross_refs

    Parameters: | asset_group_id – number –
    Returns: |

  `get_domain_list`()

    Get domain_id list in bbc_core (maybe used by a system administrator)

    Returns: |

  `get_domain_peerlist`(domain_id)

    Get peer list of the domain from the core node (maybe used by a system administrator)

    Parameters: | domain_id –
    Returns: |

  `get_stats`()

    Get statistics of bbc_core :return:

  `insert_transaction`(asset_group_id, tx_obj)

    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)

    (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)

    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)

    Request bbc_core to send ping to all its neighbors :param domain_id: :return:

  `receiver_loop`()
  `register_asset_group`(domain_id, asset_group_id, storage_type=1, storage_path=None, advertise_in_domain0=False, max_body_size=256)

    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)

    Register transaction_id in the ledger_subsystem

    Parameters: | asset_group_id – transaction_id –
    Returns: |

  `register_to_core`()

    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)

    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)

    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)

    Search request for transaction_data

    Parameters: | asset_group_id – transaction_id –
    Returns: |

  `search_transaction_by_userid`(asset_group_id, user_id)

    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)

    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)

    Send peer-to-peer message to the specified user_id

    Parameters: | msg – asset_group_id – dst_user_id –
    Returns: |

  `send_msg`(dat)

    (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)

    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)

    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)

    Set asset_group_id (before register_to_core)

    Parameters: | asset_group_id –
    Returns: |

  `set_callback`(callback_obj)

    Set callback object that implements message processing functions

    Parameters: | callback_obj –
    Returns: |

  `set_domain_static_node`(domain_id, node_id, ipv4, ipv6, port)

    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)

    Set user_id of the object

    Parameters: | identifier –
    Returns: |

  `start_receiver_loop`()
  `unregister_from_core`()

    Unregister and disconnect from the core node

    Returns: |

  `verify_in_ledger_subsystem`(asset_group_id, transaction_id)

    Verify transaction_id in the ledger_subsystem

    Parameters: | asset_group_id – transaction_id –
    Returns: |

class `bbc_app.` `Callback`(log=None)

  Bases: `object`

  Set of callback functions for processing received message

  `create_queue`(query_id)
  `destroy_queue`(query_id)
  `dispatch`(dat, payload_type)
  `proc_cmd_sign_request`(dat)
  `proc_notify_inserted`(dat)
  `proc_resp_asset_group_setup`(dat)
  `proc_resp_cross_ref`(dat)
  `proc_resp_domain_setup`(dat)
  `proc_resp_gather_signature`(dat)
  `proc_resp_get_config`(dat)
  `proc_resp_get_domainlist`(dat)

    Return domain_ids

    Parameters: | dat –
    Returns: | list of domain_id

  `proc_resp_get_peerlist`(dat)

    Return node info

    Parameters: | dat –
    Returns: | list of node info (the first one is that of the connecting core)

  `proc_resp_get_stats`(dat)
  `proc_resp_insert`(dat)
  `proc_resp_ledger_subsystem`(dat)
  `proc_resp_register_hash`(dat)
  `proc_resp_search_asset`(dat)
  `proc_resp_search_by_userid`(dat)
  `proc_resp_search_transaction`(dat)
  `proc_resp_set_peer`(dat)
  `proc_resp_sign_request`(dat)
  `proc_resp_verify_hash`(dat)
  `proc_user_message`(dat)
  `set_logger`(log)
  `sync_by_queryid`(query_id, timeout=None)

    Wait for message with specified query_id

    Parameters: | query_id – timeout – timeout second for waiting
    Returns: |

  `synchronize`(timeout=None)

    Wait for receiving message

    Parameters: | timeout – timeout second for waiting
    Returns: |

`bbc_app.` `get_id_from_mappings`(name, asset_group_id)

`bbc_app.` `get_list_from_mappings`(asset_group_id)

`bbc_app.` `remove_id_mappings`(name, asset_group_id)

`bbc_app.` `store_id_mappings`(name, asset_group_id, transaction_id=None, asset_ids=None)