Welcome to bbc1’s documentation!¶
bbc1 package¶
Subpackages¶
bbc1.core package¶
Submodules¶
bbc1.core.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.
-
class
bbc1.core.bbc_app.
BBcAppClient
(host='127.0.0.1', port=9000, multiq=True, logname='-', loglevel='none')[source]¶ Bases:
object
Basic functions for a client of bbc_core
-
cancel_insert_completion_notification
(asset_group_id)[source]¶ Cancel notification when a transaction has been inserted (as a copy of transaction)
Parameters: asset_group_id (bytes) – asset_group_id for requesting notification about insertion Returns: query_id Return type: bytes
-
count_transactions
(asset_group_id=None, asset_id=None, user_id=None, start_from=None, until=None)[source]¶ Count transactions that matches the given conditions
If multiple conditions are specified, they are considered as AND condition.
Parameters: - asset_group_id (bytes) – asset_group_id in BBcEvent and BBcRelations
- asset_id (bytes) – asset_id in BBcAsset
- user_id (bytes) – user_id in BBcAsset that means the owner of the asset
- start_from (int) – the starting timestamp to search
- until (int) – the end timestamp to search
Returns: the number of transactions
Return type: int
-
domain_close
(domain_id=None)[source]¶ Close domain leading to remove_domain in the core
Parameters: domain_id (bytes) – domain_id to delete Returns: query_id Return type: bytes
-
domain_setup
(domain_id, config=None)[source]¶ Set up domain with the specified network module and storage
This method should be used by a system administrator.
Parameters: - domain_id (bytes) – domain_id to create
- config (str) – system config in json format
Returns: query_id
Return type: bytes
-
gather_signatures
(txobj, reference_obj=None, asset_files=None, destinations=None, anycast=False)[source]¶ Request to gather signatures from the specified user_ids
Parameters: - txobj (BBcTransaction) –
- reference_obj (BBcReference) – BBcReference object that includes the information about destinations
- asset_files (dict) – mapping from asset_id to its file content
- destinations (list) – list of destination user_ids
- anycast (bool) – True if this message is for anycasting
Returns: query_id
Return type: bytes
-
get_bbc_config
()[source]¶ Get config file of bbc_core
This method should be used by a system administrator.
Returns: query_id Return type: bytes
-
get_domain_neighborlist
(domain_id)[source]¶ Get peer list of the domain from the core node
This method should be used by a system administrator.
Parameters: domain_id (bytes) – domain_id of the neighbor list Returns: query_id Return type: bytes
-
get_forwarding_list
()[source]¶ Get forwarding_list of the domain in the core node
Returns: query_id Return type: bytes
-
get_notification_list
()[source]¶ Get notification_list of the core node
Returns: query_id Return type: bytes
-
get_user_list
()[source]¶ Get user_ids in the domain that are connecting to the core node
Returns: query_id Return type: bytes
-
include_cross_ref
(txobj)[source]¶ Include BBcCrossRef from other domains in the transaction
If the client object has one or more cross_ref objects, one of them is included in the given transaction. This method should be voluntarily called for inter-domain weak collaboration.
Parameters: txobj (BBcTransaction) – Transaction object to include cross_ref
-
insert_transaction
(txobj)[source]¶ Request to insert a legitimate transaction
Parameters: txobj (BBcTransaction) – Transaction object to insert Returns: query_id Return type: bytes
-
manipulate_ledger_subsystem
(enable=False, domain_id=None)[source]¶ Start/stop ledger_subsystem on the bbc_core
This method should be used by a system administrator.
Parameters: - enable (bool) – True->start, False->stop
- domain_id (bytes) – target domain_id to enable/disable ledger_subsystem
Returns: query_id
Return type: bytes
-
notify_domain_key_update
()[source]¶ Notify update of bbc_core
This method should be used by a system administrator.
Returns: query_id Return type: bytes
-
register_in_ledger_subsystem
(asset_group_id, transaction_id)[source]¶ Register transaction_id in the ledger_subsystem
Parameters: - asset_group_id (bytes) –
- transaction_id (bytes) – the target transaction_id
Returns: query_id
Return type: bytes
-
register_to_core
(on_multiple_nodes=False)[source]¶ Register the client (user_id) to the core node
After that, the client can communicate with the core node.
Parameters: on_multiple_nodes (bool) – True if this user_id is for multicast address Returns: True Return type: bool
-
request_cross_ref_holders_list
()[source]¶ Request the list of transaction_ids that are registered as cross_ref in outer domains
Returns: query_id Return type: bytes
-
request_insert_completion_notification
(asset_group_id)[source]¶ Request notification when a transaction has been inserted (as a copy of transaction)
Parameters: asset_group_id (bytes) – asset_group_id for requesting notification about insertion Returns: query_id Return type: bytes
-
request_to_repair_asset
(asset_group_id, asset_id)[source]¶ Request to repair compromised asset file
Parameters: - asset_group_id (bytes) – the asset_group_id of the target asset
- asset_id (bytes) – the target asset_id
Returns: query_id
Return type: bytes
-
request_to_repair_transaction
(transaction_id)[source]¶ Request to repair compromised transaction data
Parameters: transaction_id (bytes) – the target transaction to repair Returns: query_id Return type: bytes
-
request_verify_by_cross_ref
(transaction_id)[source]¶ Request to verify the transaction by Cross_ref in transaction of outer domain
Parameters: transaction_id (bytes) – the target transaction_id Returns: query_id Return type: bytes
-
search_transaction
(transaction_id)[source]¶ Search request for a transaction
Parameters: transaction_id (bytes) – the target transaction to retrieve Returns: query_id Return type: bytes
-
search_transaction_with_condition
(asset_group_id=None, asset_id=None, user_id=None, start_from=None, until=None, direction=0, count=0)[source]¶ Search transaction data by asset_group_id/asset_id/user_id
If multiple conditions are specified, they are considered as AND condition.
Parameters: - asset_group_id (bytes) – asset_group_id in BBcEvent and BBcRelations
- asset_id (bytes) – asset_id in BBcAsset
- user_id (bytes) – user_id in BBcAsset that means the owner of the asset
- start_from (int) – the starting timestamp to search
- until (int) – the end timestamp to search
- direction (int) – 0: descend, 1: ascend
- count (int) – the number of transactions to retrieve
Returns: query_id
Return type: bytes
-
send_domain_ping
(domain_id, ipv4=None, ipv6=None, port=6641)[source]¶ Send domain ping to notify the existence of the node
This method should be used by a system administrator.
Parameters: - domain_id (bytes) – target domain_id to send ping
- ipv4 (str) – IPv4 address of the node
- ipv6 (str) – IPv6 address of the node
- port (int) – Port number to wait messages UDP
Returns: query_id
Return type: bytes
-
send_message
(msg, dst_user_id, is_anycast=False)[source]¶ Send a message to the specified user_id
Parameters: - msg (dict) – message to send
- dst_user_id (bytes) – destination user_id
- is_anycast (bool) – If true, the message is treated as an anycast message.
Returns: query_id
Return type: bytes
-
sendback_denial_of_sign
(dest_user_id=None, transaction_id=None, reason_text=None, query_id=None)[source]¶ Send back the denial of sign the transaction
This method is called if the receiver (signer) denies the transaction.
Parameters: - dest_user_id (bytes) – destination user_id to send back
- transaction_id (bytes) –
- reason_text (str) – message to the requester about why the node denies the transaction
- query_id – The query_id that was in the received SIGN_REQUEST message
Returns: query_id
Return type: bytes
-
sendback_signature
(dest_user_id=None, transaction_id=None, ref_index=-1, signature=None, query_id=None)[source]¶ Send back the signed transaction to the source
This method is called if the receiver (signer) approves the transaction.
Parameters: - dest_user_id (bytes) – destination user_id to send back
- transaction_id (bytes) –
- ref_index (int) – (optional) which reference in transaction the signature is for
- signature (BBcSignature) – Signature that expresses approval of the transaction with transaction_id
- query_id – The query_id that was in the received SIGN_REQUEST message
Returns: query_id
Return type: bytes
-
set_callback
(callback_obj)[source]¶ Set callback object that implements message processing functions
Parameters: callback_obj (obj) – callback method object
-
set_domain_id
(domain_id)[source]¶ Set domain_id to this client to include it in all messages
Parameters: domain_id (bytes) – domain_id to join in
-
set_domain_static_node
(domain_id, node_id, ipv4, ipv6, port)[source]¶ Set static node to the core node
IPv6 is used for socket communication if both IPv4 and IPv6 is specified. This method should be used by a system administrator.
Parameters: - domain_id (bytes) – target domain_id to set static neighbor entry
- node_id (bytes) – node_id to register
- ipv4 (str) – IPv4 address of the node
- ipv6 (str) – IPv6 address of the node
- port (int) – Port number to wait messages (UDP/TCP)
Returns: query_id
Return type: bytes
-
set_keypair
(keypair)[source]¶ Set keypair for the user
Parameters: keypair (KeyPair) – KeyPair object for signing
-
set_node_key
(pem_file=None)[source]¶ Set node_key to this client
Parameters: pem_file (str) – path string for the pem file
-
set_user_id
(identifier)[source]¶ Set user_id of the object
Parameters: identifier (bytes) – user_id of this clients
-
traverse_transactions
(transaction_id, asset_group_id=None, user_id=None, start_from=None, until=None, direction=1, hop_count=3)[source]¶ Search request for transactions
The method traverses the transaction graph in the ledger. The response from the bbc_core includes the list of transactions.
Parameters: - transaction_id (bytes) – the target transaction to retrieve
- asset_group_id (bytes) – asset_group_id that target transactions should have
- user_id (bytes) – user_id that target transactions should have
- start_from (int) – the starting timestamp to search
- until (int) – the end timestamp to search
- direction (int) – 1:backforward, non-1:forward
- hop_count (int) – hop count to traverse from the specified origin point
Returns: query_id
Return type: bytes
-
-
class
bbc1.core.bbc_app.
Callback
(log=None)[source]¶ Bases:
object
Set of callback functions for processing received message
If you want to implement your own way to process messages, inherit this class.
-
proc_cmd_sign_request
(dat)[source]¶ Callback for message REQUEST_SIGNATURE
This method should be overridden if you want to process the message asynchronously.
Parameters: dat (dict) – received message
-
proc_notify_cross_ref
(dat)[source]¶ Callback for message NOTIFY_CROSS_REF
This method must not be overridden.
Parameters: dat (dict) – received message
-
proc_notify_inserted
(dat)[source]¶ Callback for message NOTIFY_INSERTED
This method should be overridden if you want to process the message asynchronously.
Parameters: dat (dict) – received message
-
proc_resp_count_transactions
(dat)[source]¶ Callback for message RESPONSE_COUNT_TRANSACTIONS
This method should be overridden if you want to process the message asynchronously.
Parameters: dat (dict) – received message
-
proc_resp_cross_ref_list
(dat)[source]¶ Callback for message RESPONSE_CROSS_REF_LIST
This method should be overridden if you want to process the message asynchronously.
Parameters: dat (dict) – received message
-
proc_resp_domain_close
(dat)[source]¶ Callback for message RESPONSE_CLOSE_DOMAIN
This method should be overridden if you want to process the message asynchronously.
Parameters: dat (dict) – received message
-
proc_resp_domain_setup
(dat)[source]¶ Callback for message RESPONSE_SETUP_DOMAIN
This method should be overridden if you want to process the message asynchronously.
Parameters: dat (dict) – received message
-
proc_resp_ecdh_key_exchange
(dat)[source]¶ Callback for message RESPONSE_ECDH_KEY_EXCHANGE
This method must not be overridden.
Parameters: dat (dict) – received message
-
proc_resp_gather_signature
(dat)[source]¶ Callback for message RESPONSE_GATHER_SIGNATURE
This method should be overridden if you want to process the message asynchronously.
Parameters: dat (dict) – received message
-
proc_resp_get_config
(dat)[source]¶ Callback for message RESPONSE_GET_CONFIG
This method should be overridden if you want to process the message asynchronously.
Parameters: dat (dict) – received message
-
proc_resp_get_domainlist
(dat)[source]¶ Callback for message RESPONSE_GET_DOMAINLIST
List of domain_ids is queued rather than message itself. This method should be overridden if you want to process the message asynchronously.
Parameters: dat (dict) – received message
-
proc_resp_get_forwardinglist
(dat)[source]¶ Callback for message RESPONSE_GET_FORWARDING_LIST
List of user_ids in other core nodes is queued rather than message itself. This method should be overridden if you want to process the message asynchronously.
Parameters: dat (dict) – received message
-
proc_resp_get_neighborlist
(dat)[source]¶ Callback for message RESPONSE_GET_NEIGHBORLIST
List of neighbor node info (the first one is that of the connecting core) is queued rather than message itself. This method must not be overridden.
Parameters: dat (dict) – received message
-
proc_resp_get_node_id
(dat)[source]¶ Callback for message RESPONSE_GET_NODEID
Node_id is queued rather than message itself. This method should be overridden if you want to process the message asynchronously.
Parameters: dat (dict) – received message
-
proc_resp_get_notificationlist
(dat)[source]¶ Callback for message RESPONSE_GET_NOTIFICATION_LIST
List of user_ids in other core nodes is queued rather than message itself. This method should be overridden if you want to process the message asynchronously.
Parameters: dat (dict) – received message
-
proc_resp_get_stats
(dat)[source]¶ Callback for message RESPONSE_GET_STATS
This method should be overridden if you want to process the message asynchronously.
Parameters: dat (dict) – received message
-
proc_resp_get_userlist
(dat)[source]¶ Callback for message RESPONSE_GET_USERS
List of user_ids is queued rather than message itself. This method should be overridden if you want to process the message asynchronously.
Parameters: dat (dict) – received message
-
proc_resp_insert
(dat)[source]¶ Callback for message RESPONSE_INSERT
This method should be overridden if you want to process the message asynchronously.
Parameters: dat (dict) – received message
-
proc_resp_ledger_subsystem
(dat)[source]¶ Callback for message RESPONSE_MANIP_LEDGER_SUBSYS
This method should be overridden if you want to process the message asynchronously.
Parameters: dat (dict) – received message
-
proc_resp_register_hash
(dat)[source]¶ Callback for message RESPONSE_REGISTER_HASH_IN_SUBSYS
This method should be overridden if you want to process the message asynchronously.
Parameters: dat (dict) – received message
-
proc_resp_search_transaction
(dat)[source]¶ Callback for message RESPONSE_SEARCH_TRANSACTION
This method should be overridden if you want to process the message asynchronously.
Parameters: dat (dict) – received message
-
proc_resp_search_with_condition
(dat)[source]¶ Callback for message RESPONSE_SEARCH_WITH_CONDITIONS
This method should be overridden if you want to process the message asynchronously.
Parameters: dat (dict) – received message
-
proc_resp_set_neighbor
(dat)[source]¶ Callback for message RESPONSE_SET_STATIC_NODE
This method should be overridden if you want to process the message asynchronously.
Parameters: dat (dict) – received message
-
proc_resp_sign_request
(dat)[source]¶ Callback for message RESPONSE_SIGNATURE
This method should be overridden if you want to process the message asynchronously.
Parameters: dat (dict) – received message
-
proc_resp_traverse_transactions
(dat)[source]¶ Callback for message RESPONSE_TRAVERSE_TRANSACTIONS
This method should be overridden if you want to process the message asynchronously.
Parameters: dat (dict) – received message
-
proc_resp_verify_cross_ref
(dat)[source]¶ Callback for message RESPONSE_CROSS_REF_VERIFY
This method should be overridden if you want to process the message asynchronously.
Parameters: dat (dict) – received message
-
proc_resp_verify_hash
(dat)[source]¶ Callback for message RESPONSE_VERIFY_HASH_IN_SUBSYS
This method should be overridden if you want to process the message asynchronously.
Parameters: dat (dict) – received message
-
proc_user_message
(dat)[source]¶ Callback for message MESSAGE
This method should be overridden if you want to process the message asynchronously.
Parameters: dat (dict) – received message
-
sync_by_queryid
(query_id, timeout=None, no_delete_q=False)[source]¶ Wait for the message with specified query_id
This method creates a queue for the query_id and waits for the response
Parameters: - query_id (byte) – timeout for waiting a message in seconds
- timeout (int) – timeout for waiting a message in seconds
- no_delete_q (bool) – If True, the queue for the query_id remains after popping a message
Returns: a received message
Return type: dict
-
bbc1.core.bbc_config 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.
-
class
bbc1.core.bbc_config.
BBcConfig
(directory=None, file=None, default_confpath=None)[source]¶ Bases:
object
System configuration
-
get_domain_config
(domain_id, create_if_new=False)[source]¶ Return the part of specified domain_id in the config dictionary
-
bbc1.core.bbc_core module¶
:” .
exec python “$0” “$@”
-
class
bbc1.core.bbc_core.
BBcCoreService
(p2p_port=None, core_port=None, use_domain0=False, ip4addr=None, ip6addr=None, workingdir='.bbc1', configfile=None, use_nodekey=None, use_ledger_subsystem=False, default_conffile=None, loglevel='all', logname='-', server_start=True)[source]¶ Bases:
object
Base service object of BBc-1
-
count_transactions
(domain_id, asset_group_id=None, asset_id=None, user_id=None, start_from=None, until=None)[source]¶ Count transactions that match given conditions
When Multiple conditions are given, they are considered as AND condition.
Parameters: - domain_id (bytes) – target domain_id
- asset_group_id (bytes) – asset_group_id that target transactions should have
- asset_id (bytes) – asset_id that target transactions should have
- user_id (bytes) – user_id that target transactions should have
- start_from (int) – the starting timestamp to search
- until (int) – the end timestamp to search
Returns: the number of transactions
Return type: int
-
insert_transaction
(domain_id, txdata, asset_files)[source]¶ Insert transaction into ledger
Parameters: - domain_id (bytes) – target domain_id
- txdata (bytes) – serialized transaction data
- asset_files (dict) – dictionary of {asset_id: content} for the transaction
Returns: inserted transaction_id or error message
Return type: dict|str
-
remove_from_notification_list
(domain_id, asset_group_id, user_id)[source]¶ Remove entry from insert completion notification list
This method checks validation only.
Parameters: - domain_id (bytes) – target domain_id
- asset_group_id (bytes) – target asset_group_id of which you want to get notification about the insertion
- user_id (bytes) – user_id that registers in the list
-
search_transaction_with_condition
(domain_id, asset_group_id=None, asset_id=None, user_id=None, start_from=None, until=None, direction=0, count=0)[source]¶ Search transactions that match given conditions
When Multiple conditions are given, they are considered as AND condition.
Parameters: - domain_id (bytes) – target domain_id
- asset_group_id (bytes) – asset_group_id that target transactions should have
- asset_id (bytes) – asset_id that target transactions should have
- user_id (bytes) – user_id that target transactions should have
- start_from (int) – the starting timestamp to search
- until (int) – the end timestamp to search
- direction (int) – 0: descend, 1: ascend
- count (int) – The maximum number of transactions to retrieve (if count <= 0, then self.search_max_count is applied)
Returns: dictionary having transaction_id, serialized transaction data, asset files
Return type: dict
-
send_inserted_notification
(domain_id, asset_group_ids, transaction_id, only_registered_user=False)[source]¶ Broadcast NOTIFY_INSERTED
Parameters: - domain_id (bytes) – target domain_id
- asset_group_ids (list) – list of asset_group_ids
- transaction_id (bytes) – transaction_id that has just inserted
- only_registered_user (bool) – If True, notification is not sent to other nodes
-
validate_transaction
(txdata, asset_files=None)[source]¶ Validate transaction by verifying signature
Parameters: - txdata (bytes) – serialized transaction data
- asset_files (dict) – dictionary of {asset_id: content} for the transaction
Returns: if validation fails, None returns. int (short): 2-byte value of BBcFormat type or None
Return type: BBcTransaction
-
bbc1.core.bbc_error 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.
bbc1.core.bbc_network 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.
-
class
bbc1.core.bbc_network.
BBcNetwork
(config, core=None, p2p_port=None, external_ip4addr=None, external_ip6addr=None, loglevel='all', logname=None)[source]¶ Bases:
object
Socket and thread management for infrastructure layers
-
CONFIRM_KEY_EXCHANGE
= b'\x00\x03'¶
-
NOTIFY_LEAVE
= b'\x00\x00'¶
-
REQUEST_KEY_EXCHANGE
= b'\x00\x01'¶
-
RESPONSE_KEY_EXCHANGE
= b'\x00\x02'¶
-
add_neighbor
(domain_id, node_id, ipv4=None, ipv6=None, port=None, is_static=False)[source]¶ Add node in the neighbor list
Parameters: - domain_id (bytes) – target domain_id
- node_id (bytes) – target node_id
- ipv4 (str) – IPv4 address of the node
- ipv6 (str) – IPv6 address of the node
- port (int) – Port number that the node is waiting at
- is_static (bool) – If true, the entry is treated as static one and will be saved in config.json
Returns: True if it is a new entry, None if error.
Return type: bool
-
broadcast_message_in_network
(domain_id, payload_type=1, msg=None)[source]¶ Send message to all neighbor nodes
Parameters: - payload_type (bytes) – message format type
- domain_id (bytes) – target domain_id
- msg (dict) – message to send
Returns: True if successful
Return type: bool
-
check_admin_signature
(domain_id, msg)[source]¶ Check admin signature in the message
Parameters: - domain_id (bytes) – target domain_id
- msg (dict) – received message
Returns: True if valid
Return type: bool
-
create_domain
(domain_id=b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', config=None)[source]¶ Create domain and register user in the domain
Parameters: - domain_id (bytes) – target domain_id to create
- config (dict) – configuration for the domain
Returns: Return type: bool
-
get_domain_keypair
(domain_id)[source]¶ Get domain_keys (private key and public key)
Parameters: domain_id (bytes) – target domain_id
-
include_admin_info_into_message_if_needed
(domain_id, msg, admin_info)[source]¶ Serialize admin info into one binary object and add signature
-
remove_domain
(domain_id=b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00')[source]¶ Leave the domain and remove it
Parameters: domain_id (bytes) – target domain_id to remove Returns: True if successful Return type: bool
-
send_domain_ping
(domain_id, ipv4, ipv6, port, is_static=False)[source]¶ Send domain ping to the specified node
Parameters: - domain_id (bytes) – target domain_id
- ipv4 (str) – IPv4 address of the node
- ipv6 (str) – IPv6 address of the node
- port (int) – Port number
- is_static (bool) – If true, the entry is treated as static one and will be saved in config.json
Returns: True if successful
Return type: bool
-
send_key_exchange_message
(domain_id, node_id, command, pubkey, nonce, random_val, key_name)[source]¶ Send ECDH key exchange message
-
send_message_in_network
(nodeinfo=None, payload_type=1, domain_id=None, msg=None)[source]¶ Send message over a domain network
Parameters: - nodeinfo (NodeInfo) – NodeInfo object of the destination
- payload_type (bytes) – message format type
- domain_id (bytes) – target domain_id
- msg (dict) – message to send
Returns: True if successful
Return type: bool
-
-
class
bbc1.core.bbc_network.
NeighborInfo
(network=None, domain_id=None, node_id=None, my_info=None)[source]¶ Bases:
object
Manage information of neighbor nodes
-
NODEINFO_LIFETIME
= 900¶
-
PURGE_INTERVAL_SEC
= 300¶
-
-
class
bbc1.core.bbc_network.
NodeInfo
(node_id=None, ipv4=None, ipv6=None, port=None, is_static=False, domain0=False)[source]¶ Bases:
object
Node information entry
-
SECURITY_STATE_CONFIRMING
= 2¶
-
SECURITY_STATE_ESTABLISHED
= 3¶
-
SECURITY_STATE_NONE
= 0¶
-
SECURITY_STATE_REQUESTING
= 1¶
-
get_nodeinfo
()[source]¶ Return a list of node info
Returns: [node_id, ipv4, ipv6, port, domain0_flag, update_at] Return type: list
-
update
(ipv4=None, ipv6=None, port=None, seq=None, domain0=None)[source]¶ Update the entry
Parameters: - ipv4 (str) – IPv4 address of the sender node
- ipv6 (str) – IPv6 address of the sender node
- port (int) – Port number of the sender
- sec (int) – message sequence number
- domain0 (bool or None) – If True, the node is domain0 manager
Returns: True if the entry has changed
Return type: bool
-
bbc1.core.bbc_stats 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.
bbc1.core.bbclib 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.
bbc1.core.command 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.
bbc1.core.data_handler 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.
-
class
bbc1.core.data_handler.
DataHandler
(networking=None, config=None, workingdir=None, domain_id=None, loglevel='all', logname=None)[source]¶ Bases:
object
DB and storage handler
-
NOTIFY_INSERTED
= b'\x00\x04'¶
-
REPAIR_TRANSACTION_DATA
= b'\x00\x05'¶
-
REPLICATION_ALL
= 0¶
-
REPLICATION_CROSS_REF
= b'\x00\x06'¶
-
REPLICATION_EXT
= 2¶
-
REPLICATION_P2P
= 1¶
-
REQUEST_REPLICATION_INSERT
= b'\x00\x00'¶
-
REQUEST_SEARCH
= b'\x00\x02'¶
-
RESPONSE_REPLICATION_INSERT
= b'\x00\x01'¶
-
RESPONSE_SEARCH
= b'\x00\x03'¶
-
count_domain_in_cross_ref
(outer_domain_id)[source]¶ Count the number of domains in the cross_ref table
-
count_transactions
(asset_group_id=None, asset_id=None, user_id=None, start_from=None, until=None, db_num=0)[source]¶ Count transactions that matches the given conditions
When Multiple conditions are given, they are considered as AND condition.
Parameters: - asset_group_id (bytes) – asset_group_id that target transactions should have
- asset_id (bytes) – asset_id that target transactions should have
- user_id (bytes) – user_id that target transactions should have
- start_from (int) – the starting timestamp to search
- until (int) – the end timestamp to search
- db_num (int) – index of DB if multiple DBs are used
Returns: the number of transactions
Return type: int
-
exec_sql
(db_num=0, sql=None, args=(), commit=False, fetch_one=False, return_cursor=False)[source]¶ Execute sql sentence
Parameters: - db_num (int) – index of DB if multiple DBs are used
- sql (str) – SQL string
- args (list) – Args for the SQL
- commit (bool) – If True, commit is performed
- fetch_one (bool) – If True, fetch just one record
- return_cursor (bool) – If True (and fetch_one is False), return db_cur (iterator)
Returns: list of records
Return type: list
-
get_asset_info
(txobj)[source]¶ Retrieve asset information from transaction object
Parameters: txobj (BBcTransaction) – transaction object to analyze Returns: list of list [asset_group_id, asset_id, user_id, file_size, file_digest] Return type: list
-
get_in_storage
(asset_group_id, asset_id)[source]¶ Get the asset file with the asset_id from local storage
Parameters: - asset_group_id (bytes) – asset_group_id of the asset
- asset_id (bytes) – asset_id of the asset
Returns: the file content
Return type: bytes or None
-
insert_cross_ref
(transaction_id, outer_domain_id, txid_having_cross_ref, no_replication=False)[source]¶ Insert cross_ref information into cross_ref_table
Parameters: - transaction_id (bytes) – target transaction_id
- outer_domain_id (bytes) – domain_id that holds cross_ref about the transaction_id
- txid_having_cross_ref (bytes) – transaction_id in the outer_domain that includes the cross_ref
- no_replication (bool) – If False, the replication is sent to other nodes in the domain
-
insert_transaction
(txdata, txobj=None, fmt_type=0, asset_files=None, no_replication=False)[source]¶ Insert transaction data and its asset files
Either txdata or txobj must be given to insert the transaction.
Parameters: - txdata (bytes) – serialized transaction data
- txobj (BBcTransaction) – transaction object to insert
- fmt_type (int) – 2-byte value of BBcFormat type
- asset_files (dict) – asset files in the transaction
Returns: set of asset_group_ids in the transaction
Return type: set
-
remove
(transaction_id, txobj=None, db_num=-1)[source]¶ Delete all data regarding the specified transaction_id
This method requires either transaction_id or txobj.
Parameters: - transaction_id (bytes) – target transaction_id
- txobj (BBcTransaction) – transaction object to remove
- db_num (int) – index of DB if multiple DBs are used
-
search_domain_having_cross_ref
(transaction_id=None)[source]¶ Search domain_id that holds cross_ref about the specified transaction_id
Parameters: transaction_id (bytes) – target transaction_id Returns: records of cross_ref_tables [“id”,”transaction_id”, “outer_domain_id”, “txid_having_cross_ref”] Return type: list
-
search_transaction
(transaction_id=None, asset_group_id=None, asset_id=None, user_id=None, start_from=None, until=None, direction=0, count=1, db_num=0)[source]¶ Search transaction data
When Multiple conditions are given, they are considered as AND condition.
Parameters: - transaction_id (bytes) – target transaction_id
- asset_group_id (bytes) – asset_group_id that target transactions should have
- asset_id (bytes) – asset_id that target transactions should have
- user_id (bytes) – user_id that target transactions should have
- start_from (int) – the starting timestamp to search
- until (int) – the end timestamp to search
- direction (int) – 0: descend, 1: ascend
- count (int) – The maximum number of transactions to retrieve
- db_num (int) – index of DB if multiple DBs are used
Returns: mapping from transaction_id to serialized transaction data dict: dictionary of {asset_id: content} for the transaction
Return type: dict
-
search_transaction_topology
(transaction_id, traverse_to_past=True)[source]¶ Search in topology info
Parameters: - transaction_id (bytes) – base transaction_id
- traverse_to_past (bool) – True: search backward (to past), False: search forward (to future)
Returns: list of records of topology table
Return type: list
-
store_in_storage
(asset_group_id, asset_id, content, do_overwrite=False)[source]¶ Store asset file in local storage
Parameters: - asset_group_id (bytes) – asset_group_id of the asset
- asset_id (bytes) – asset_id of the asset
- content (bytes) – the content of the asset file
- do_overwrite (bool) – If True, file is overwritten
Returns: True if successful
Return type: bool
-
-
class
bbc1.core.data_handler.
DataHandlerDomain0
(networking=None, config=None, workingdir=None, domain_id=None, loglevel='all', logname=None)[source]¶ Bases:
bbc1.core.data_handler.DataHandler
Data handler for domain_global_0
-
exec_sql
(sql, *args)[source]¶ Execute sql sentence
Parameters: - db_num (int) – index of DB if multiple DBs are used
- sql (str) – SQL string
- args (list) – Args for the SQL
- commit (bool) – If True, commit is performed
- fetch_one (bool) – If True, fetch just one record
- return_cursor (bool) – If True (and fetch_one is False), return db_cur (iterator)
Returns: list of records
Return type: list
-
get_asset_info
(txobj)[source]¶ Retrieve asset information from transaction object
Parameters: txobj (BBcTransaction) – transaction object to analyze Returns: list of list [asset_group_id, asset_id, user_id, file_size, file_digest] Return type: list
-
get_in_storage
(asset_group_id, asset_id)[source]¶ Get the asset file with the asset_id from local storage
Parameters: - asset_group_id (bytes) – asset_group_id of the asset
- asset_id (bytes) – asset_id of the asset
Returns: the file content
Return type: bytes or None
-
insert_transaction
(txdata, txobj=None, asset_files=None, no_replication=False)[source]¶ Insert transaction data and its asset files
Either txdata or txobj must be given to insert the transaction.
Parameters: - txdata (bytes) – serialized transaction data
- txobj (BBcTransaction) – transaction object to insert
- fmt_type (int) – 2-byte value of BBcFormat type
- asset_files (dict) – asset files in the transaction
Returns: set of asset_group_ids in the transaction
Return type: set
-
remove
(transaction_id)[source]¶ Delete all data regarding the specified transaction_id
This method requires either transaction_id or txobj.
Parameters: - transaction_id (bytes) – target transaction_id
- txobj (BBcTransaction) – transaction object to remove
- db_num (int) – index of DB if multiple DBs are used
-
search_transaction
(transaction_id=None, asset_group_id=None, asset_id=None, user_id=None, count=1)[source]¶ Search transaction data
When Multiple conditions are given, they are considered as AND condition.
Parameters: - transaction_id (bytes) – target transaction_id
- asset_group_id (bytes) – asset_group_id that target transactions should have
- asset_id (bytes) – asset_id that target transactions should have
- user_id (bytes) – user_id that target transactions should have
- start_from (int) – the starting timestamp to search
- until (int) – the end timestamp to search
- direction (int) – 0: descend, 1: ascend
- count (int) – The maximum number of transactions to retrieve
- db_num (int) – index of DB if multiple DBs are used
Returns: mapping from transaction_id to serialized transaction data dict: dictionary of {asset_id: content} for the transaction
Return type: dict
-
search_transaction_topology
(transaction_id, reverse_link=False)[source]¶ Search in topology info
Parameters: - transaction_id (bytes) – base transaction_id
- traverse_to_past (bool) – True: search backward (to past), False: search forward (to future)
Returns: list of records of topology table
Return type: list
-
store_in_storage
(asset_group_id, asset_id, content)[source]¶ Store asset file in local storage
Parameters: - asset_group_id (bytes) – asset_group_id of the asset
- asset_id (bytes) – asset_id of the asset
- content (bytes) – the content of the asset file
- do_overwrite (bool) – If True, file is overwritten
Returns: True if successful
Return type: bool
-
-
class
bbc1.core.data_handler.
DbAdaptor
(handler=None, db_name=None, db_num=0, loglevel='all', logname=None)[source]¶ Bases:
object
Base class for DB adaptor
-
class
bbc1.core.data_handler.
MysqlAdaptor
(handler=None, db_name=None, db_num=None, server_info=None, loglevel='all', logname=None)[source]¶ Bases:
bbc1.core.data_handler.DbAdaptor
DB adaptor for MySQL
-
create_table
(tbl, tbl_definition, primary_key=0, indices=[])[source]¶ Create a table
Parameters: - tbl (str) – table name
- tbl_definition (list) – schema of the table [[“column_name”, “data type”],[“colmun_name”, “data type”],,]
- primary_key (int) – index (column) of the primary key of the table
- indices (list) – list of indices to create index
-
-
class
bbc1.core.data_handler.
SqliteAdaptor
(handler=None, db_name=None, loglevel='all', logname=None)[source]¶ Bases:
bbc1.core.data_handler.DbAdaptor
DB adaptor for SQLite3
-
create_table
(tbl, tbl_definition, primary_key=0, indices=[])[source]¶ Create a table
Parameters: - tbl (str) – table name
- tbl_definition (list) – schema of the table [[“column_name”, “data type”],[“colmun_name”, “data type”],,]
- primary_key (int) – index (column) of the primary key of the table
- indices (list) – list of indices to create index
-
bbc1.core.domain0_manager 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.
-
class
bbc1.core.domain0_manager.
Domain0Manager
(networking=None, node_id=None, loglevel='all', logname=None)[source]¶ Bases:
object
Management for inter-domain collaboration over domain_global_0
-
ADV_DOMAIN_LIST
= b'\x00\x00'¶
-
CROSS_REF_PROBABILITY
= 0.1¶
-
DISTRIBUTE_CROSS_REF
= b'\x00\x01'¶
-
DOMAIN_ACCEPTANCE_RECOVER_INTERVAL
= 600¶
-
DOMAIN_INFO_ADVERTISE_INTERVAL
= 1800¶
-
DOMAIN_INFO_LIFETIME
= 3600¶
-
INITIAL_ACCEPT_LIMIT
= 10¶
-
NOTIFY_CROSS_REF_REGISTERED
= b'\x00\x02'¶
-
NUM_OF_COPIES
= 3¶
-
REQUEST_VERIFY
= b'\x00\x04'¶
-
REQUEST_VERIFY_FROM_OUTER_DOMAIN
= b'\x00\x05'¶
-
RESPONSE_VERIFY_FROM_OUTER_DOMAIN
= b'\x00\x06'¶
-
cross_ref_registered
(domain_id, transaction_id, cross_ref)[source]¶ Notify cross_ref inclusion in a transaction of the outer domain and insert the info into DB
Parameters: - domain_id (bytes) – domain_id where the cross_ref is from
- transaction_id (bytes) – transaction_id that the cross_ref proves
- cross_ref (bytes) – the registered cross_ref in other domain
-
bbc1.core.key_exchange_manager 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.
-
class
bbc1.core.key_exchange_manager.
KeyExchangeManager
(networking, domain_id, counter_node_id)[source]¶ Bases:
object
ECDH (Elliptic Curve Diffie-Hellman) key exchange manager
-
KEY_EXCHANGE_INVOKE_MAX_BACKOFF
= 6¶
-
KEY_EXCHANGE_RETRY_INTERVAL
= 5¶
-
KEY_OBSOLETE_TIMER
= 10¶
-
KEY_REFRESH_INTERVAL
= 604800¶
-
STATE_CONFIRMING
= 2¶
-
STATE_ESTABLISHED
= 3¶
-
STATE_NONE
= 0¶
-
STATE_REQUESTING
= 1¶
-
receive_exchange_request
(pubkey, nonce, random_val, hint)[source]¶ Procedure when receiving message with BBcNetwork.REQUEST_KEY_EXCHANGE
Parameters: - pubkey (bytes) – public key
- nonce (bytes) – nonce value
- random_val (bytes) – random value in calculating key
-
bbc1.core.logger 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.
bbc1.core.message_key_types 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.
-
class
bbc1.core.message_key_types.
InfraMessageCategory
[source]¶ Bases:
object
Types of message for inter-core nodes messaging
-
CATEGORY_DATA
= b'\x00\x03'¶
-
CATEGORY_DOMAIN0
= b'\x00\x04'¶
-
CATEGORY_NETWORK
= b'\x00\x00'¶
-
CATEGORY_TOPOLOGY
= b'\x00\x01'¶
-
CATEGORY_USER
= b'\x00\x02'¶
-
-
class
bbc1.core.message_key_types.
KeyType
[source]¶ Bases:
object
Types of items in a message
-
admin_info
= b'\x00\x00\x00\x17'¶
-
all_asset_files
= b'\x00\x00\x00u'¶
-
all_included
= b'\x00\x00\x00h'¶
-
anycast_ttl
= b'\x00\x00\x00\x1a'¶
-
asset_file
= b'\x00\x00\x00t'¶
-
asset_group_id
= b'\x00\x00\x00c'¶
-
asset_group_ids
= b'\x00\x00\x00d'¶
-
asset_id
= b'\x00\x00\x00e'¶
-
bbc_configuration
= b'\x00\x00\x00<'¶
-
command
= b'\x00\x00\x00\t'¶
-
compromised_asset_files
= b'\x00\x00\x00\x92'¶
-
compromised_transaction_data
= b'\x00\x00\x00\x90'¶
-
compromised_transaction_ids
= b'\x00\x00\x00\x93'¶
-
compromised_transactions
= b'\x00\x00\x00\x91'¶
-
count
= b'\x00\x00\x00\x0e'¶
-
cross_ref
= b'\x00\x00\x00w'¶
-
cross_ref_verification_info
= b'\x00\x00\x00{'¶
-
destination_node_id
= b'\x00\x00\x00V'¶
-
destination_user_id
= b'\x00\x00\x00R'¶
-
destination_user_ids
= b'\x00\x00\x00S'¶
-
direction
= b'\x00\x00\x00f'¶
-
domain_id
= b'\x00\x00\x00P'¶
-
domain_list
= b'\x00\x00\x007'¶
-
domain_ping
= b'\x00\x00\x00\x15'¶
-
ecdh
= b'\x00\x00\x00\x11'¶
-
external_ip4addr
= b'\x00\x00\x004'¶
-
external_ip6addr
= b'\x00\x00\x005'¶
-
forwarding_list
= b'\x00\x00\x008'¶
-
hint
= b'\x00\x00\x00\x10'¶
-
hop_count
= b'\x00\x00\x00g'¶
-
infra_command
= b'\x00\x00\x00\n'¶
-
infra_msg_type
= b'\x00\x00\x00\x08'¶
-
ipv4_address
= b'\x00\x00\x001'¶
-
ipv6_address
= b'\x00\x00\x002'¶
-
is_anycast
= b'\x00\x00\x00\x19'¶
-
is_replication
= b'\x00\x00\x00\x1b'¶
-
ledger_subsys_manip
= b'\x00\x00\x00\xa0'¶
-
ledger_subsys_register
= b'\x00\x00\x00\xa1'¶
-
ledger_subsys_verify
= b'\x00\x00\x00\xa2'¶
-
merkle_tree
= b'\x00\x00\x00\xa3'¶
-
message
= b'\x00\x00\x00\x0c'¶
-
message_seq
= b'\x00\x00\x00\x14'¶
-
neighbor_list
= b'\x00\x00\x00:'¶
-
node_id
= b'\x00\x00\x00T'¶
-
node_info
= b'\x00\x00\x006'¶
-
nodekey_signature
= b'\x00\x00\x00\x16'¶
-
nonce
= b'\x00\x00\x00\r'¶
-
notification_list
= b'\x00\x00\x00;'¶
-
on_multinodes
= b'\x00\x00\x00\x18'¶
-
outer_domain_id
= b'\x00\x00\x00x'¶
-
port_number
= b'\x00\x00\x003'¶
-
query_id
= b'\x00\x00\x00\x0b'¶
-
random
= b'\x00\x00\x00\x12'¶
-
reason
= b'\x00\x00\x00\x01'¶
-
ref_index
= b'\x00\x00\x00s'¶
-
result
= b'\x00\x00\x00\x02'¶
-
retry_timer
= b'\x00\x00\x00\x13'¶
-
signature
= b'\x00\x00\x00v'¶
-
source_domain_id
= b'\x00\x00\x00y'¶
-
source_node_id
= b'\x00\x00\x00U'¶
-
source_user_id
= b'\x00\x00\x00Q'¶
-
start_from
= b'\x00\x00\x00i'¶
-
static_entry
= b'\x00\x00\x000'¶
-
stats
= b'\x00\x00\x00\x0f'¶
-
status
= b'\x00\x00\x00\x00'¶
-
transaction_data
= b'\x00\x00\x00p'¶
-
transaction_data_format
= b'\x00\x00\x00|'¶
-
transaction_id
= b'\x00\x00\x00a'¶
-
transaction_id_list
= b'\x00\x00\x00b'¶
-
transaction_tree
= b'\x00\x00\x00r'¶
-
transactions
= b'\x00\x00\x00q'¶
-
txid_having_cross_ref
= b'\x00\x00\x00z'¶
-
until
= b'\x00\x00\x00j'¶
-
user_id
= b'\x00\x00\x00`'¶
-
user_list
= b'\x00\x00\x009'¶
-
-
class
bbc1.core.message_key_types.
PayloadType
[source]¶ Bases:
object
-
Type_any
= 1¶
-
Type_binary
= 0¶
-
Type_encrypted_msgpack
= 3¶
-
Type_msgpack
= 2¶
-
-
bbc1.core.message_key_types.
convert_from_binary
(data_type, dat)[source]¶ Deserialization from simple serialization
Utility for deriving shared key in ECDH procedure
-
bbc1.core.message_key_types.
deserialize_data
(payload_type, dat)[source]¶ Utility for deserializing the received message
-
bbc1.core.message_key_types.
get_ECDH_parameters
()[source]¶ Utility for initialization of ECDH parameters
-
bbc1.core.message_key_types.
make_TLV_formatted_message
(msg)[source]¶ Utility for simple serialization function
-
bbc1.core.message_key_types.
make_binary
(dat)[source]¶ Simple serialize function
Basically, Type-Length-Value format is created for each item.
-
bbc1.core.message_key_types.
make_dictionary_from_TLV_format
(dat)[source]¶ Utility for simple deserialization function
-
bbc1.core.message_key_types.
make_message
(payload_type, msg, payload_version=0, key_name=None)[source]¶ Utility for making serialized message data
bbc1.core.query_management 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.
-
class
bbc1.core.query_management.
QueryEntry
(expire_after=30, callback_expire=None, callback=None, callback_error=None, interval=0, data={}, retry_count=-1)[source]¶ Bases:
object
Callback manager
-
update
(fire_after=None, expire_after=None, callback=None, callback_error=None, init=False)[source]¶ Update the entry information
Parameters: - fire_after (float) – set callback (periodical) to fire after given time (in second)
- expire_after (float) – set expiration timer to given time (in second)
- callback (obj) – callback method that will be called periodically
- callback_error (obj) – callback method that will be called when error happens
- init (bool) – If True, the scheduler is sorted again
-
bbc1.core.repair_manager 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.
-
class
bbc1.core.repair_manager.
RepairManager
(network=None, domain_id=None, workingdir='.', loglevel='all', logname=None)[source]¶ Bases:
object
Data repair manager for forged transaction/asset
-
REQUEST_REPAIR_ASSET_FILE
= 1¶
-
REQUEST_REPAIR_TRANSACTION
= 0¶
-
REQUEST_TO_SEND_ASSET_FILE
= 4¶
-
REQUEST_TO_SEND_TRANSACTION_DATA
= 2¶
-
RESPONSE_ASSET_FILE
= 5¶
-
RESPONSE_TRANSACTION_DATA
= 3¶
-
bbc1.core.topology_manager 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.
-
class
bbc1.core.topology_manager.
TopologyManagerBase
(network=None, config=None, domain_id=None, node_id=None, loglevel='all', logname=None)[source]¶ Bases:
object
Network topology management for a domain
This class defines how to create topology, meaning that who should be neighbors and provides very simple topology management, that is full mesh topology. If P2P routing algorithm is needed, you should override this class to upgrade functions. This class does not manage the neighbor list itself (It’s in BBcNetwork)
-
NEIGHBOR_LIST_REFRESH_INTERVAL
= 300¶
-
NOTIFY_NEIGHBOR_LIST
= b'\x00\x00'¶
-
bbc1.core.user_message_routing 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.
-
class
bbc1.core.user_message_routing.
UserMessageRouting
(networking, domain_id, loglevel='all', logname=None)[source]¶ Bases:
object
Handle message for clients
-
CROSS_REF_ASSIGNMENT
= b'\x00\x05'¶
-
JOIN_MULTICAST_RECEIVER
= b'\x00\x03'¶
-
LEAVE_MULTICAST_RECEIVER
= b'\x00\x04'¶
-
MAX_CROSS_REF_STOCK
= 10¶
-
REFRESH_FORWARDING_LIST_INTERVAL
= 300¶
-
RESOLVE_TIMEOUT
= 5¶
-
RESOLVE_USER_LOCATION
= b'\x00\x00'¶
-
RESPONSE_NO_SUCH_USER
= b'\x00\x02'¶
-
RESPONSE_USER_LOCATION
= b'\x00\x01'¶
-
register_user
(user_id, socket, on_multiple_nodes=False)[source]¶ Register user to forward message
Parameters: - user_id (bytes) – user_id of the client
- socket (Socket) – socket for the client
- on_multiple_nodes (bool) – If True, the user_id is also registered in other nodes, meaning multicasting.
-
send_message_to_user
(msg, direct_only=False)[source]¶ Forward message to connecting user
Parameters: - msg (dict) – message to send
- direct_only (bool) – If True, _forward_message_to_another_node is not called.
-
-
class
bbc1.core.user_message_routing.
UserMessageRoutingDummy
(networking, domain_id, loglevel='all', logname=None)[source]¶ Bases:
bbc1.core.user_message_routing.UserMessageRouting
Dummy class for bbc_core.py
-
register_user
(user_id, socket, on_multiple_nodes=False)[source]¶ Register user to forward message
Parameters: - user_id (bytes) – user_id of the client
- socket (Socket) – socket for the client
- on_multiple_nodes (bool) – If True, the user_id is also registered in other nodes, meaning multicasting.
-