# bbc_core module

:” .

exec python “$0” “$@”

`BBcCoreService`([p2p_port, core_port, …]) |

class `bbc_core.``BBcCoreService`(p2p_port=None, core_port=None, use_global=False, ip4addr=None, ip6addr=None, workingdir='.bbc1', configfile=None, use_ledger_subsystem=False, loglevel='all', logname='-', server_start=True)

  Bases: `object`

  `add_cross_ref_into_list`(domain_id, txid)

    (internal use) register cross_ref info in the list

    Parameters: | domain_id – txid –
    Returns: |

  `check_asset_in_response`(query_entry)

    (internal use) Check asset in the transaction

    Parameters: | query_entry –
    Returns: |

  `configure_domain`(domain_id, nw_module='simple_cluster', storage_type=0, storage_path=None)
  `distribute_transaction_to_gather_signatures`(domain_id, dat)

    Request to distribute sign_request to users

    Parameters: | domain_id – dat –
    Returns: |

  `error_reply`(msg=None, err_code=-1, txt='')
  `failure_response`(query_entry)

    (internal use) Called when transaction search fails

    Parameters: | query_entry –
    Returns: |

  `handler`(socket, address)

    Message wait loop

    Parameters: | socket – address –
    Returns: |

  `insert_transaction`(domain_id, txdata, asset_files, no_network_put=False)

    Insert transaction into ledger subsystem

    Parameters: | domain_id – domain_id where the transaction is inserted txdata – BBcTransaction data asset_files – dictionary of { asid=>asset_content,,, } no_network_put – If false, skip networking.put()

  `param_check`(param, dat)

    Check if the param is included

    Parameters: | param – string or list of strings dat –
    Returns: |

  `pop_cross_refs`(num=1)

    Return TxIDs for cross_refs

    Parameters: | num – The number of set of (txid, domain_id) to return
    Returns: |

  `process`(socket, dat, payload_type)

    Process received message

    Parameters: | socket – dat – payload_type – PayloadType value of msg
    Returns: |

  `quit_program`()
  `remove_from_notification_list`(domain_id, asset_group_id, user_id)

    Remove entry from insert completion notification list :param domain_id: :param asset_group_id: :param user_id: :return:

  `search_asset_by_asid`(domain_id, asset_group_id, asid, source_id, query_id)

    Search asset in the storage by asset_id. If not found, search it in the network

    Parameters: | domain_id – domain_id where the transaction is inserted asset_group_id – asset_group_id to search in asid – asset_id in byte format source_id – the user_id of the sender query_id –
    Returns: | dictionary data of transaction_data, asset_file (if exists)

  `search_transaction_by_txid`(domain_id, txid, source_id, query_id)

    Search transaction_data by transaction_id

    Parameters: | domain_id – domain_id where the transaction is inserted txid – transaction_id source_id – the user_id of the sender query_id –
    Returns: | response data including transaction_data

  `search_transaction_by_userid_locally`(domain_id, asset_group_id, user_id, source_id, query_id, count=1)

    Local search a latest transaction that includes the asset owned by the specified user_id :param domain_id: domain_id where the transaction is inserted :param asset_group_id: :param user_id: :param source_id: the user_id of the sender :param query_id: :return: response data including transaction_data, if a transaction is not found in the local DB, None is returned.

  `search_transaction_for_asset`(query_entry)

    (internal use) Search transaction that includes the specified asset_id

    Parameters: | query_entry –
    Returns: |

  `send_error_response`(response_info)

    (internal use) send error response

    Parameters: | response_info –
    Returns: |

  `send_message`(dat, sock=None)

    Send message to bbc_app (TCP client) :param dat: :return:

  `send_raw_message`(socket, dat)
  `send_response`(response_info, dat)

    (internal use) send response message

    Parameters: | response_info – dat –
    Returns: |

  `send_to_other_user`(domain_id, dst_user_id, src_user_id, msg)
  `start_server`(port)
  `succeed_to_find_transaction`(query_entry)

    (internal use) Called when transaction search is successful

    Parameters: | query_entry –
    Returns: |

  `validate_asset_file`(txobj, asid, asset_file)

    Validate asset in storage by verifying SHA256 digest

    Parameters: | txobj – asset_file –
    Returns: |

  `validate_transaction`(txid, txdata, asset_files=None)

    Validate transaction by verifying signature

    Parameters: | txid – transaction_id txdata – BBcTransaction data asset_files – dictionary of { asid=>asset_content,,, }

`bbc_core.``check_transaction_if_having_asset_file`(txdata, asid)

`bbc_core.``daemonize`(pidfile='/tmp/bbc1.pid')

`bbc_core.``error_response`(err_code=-255, txt='')

  (internal use) Create error response with reason text

  Parameters: | err_code – error code (defined in bbc_error.py) txt – reason text
  Returns: | dictionary type data

`bbc_core.``make_message_structure`(cmd, dstid, qid)

  (internal use) Create a base structure of message

  Parameters: | cmd – dstid – destination_user_id qid – query_id
  Returns: |