bbc_core module — BBc1 0.7 documentation

# 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, loglevel='all', logname='-', server_start=True)

  Bases: `object`

  `add_cross_ref_into_list`(asset_group_id, txid)

    (internal use) register cross_ref info in the list

    Parameters: | asset_group_id – txid –
    Returns: |

  `asset_group_setup`(domain_id, asset_group_id, storage_type=1, storage_path=None, advertise_in_domain0=False, max_body_size=256, config_update=False)

    Setup asset_group in a specified domain

    Parameters: | domain_id – asset_group_id – storage_type – storage_path – advertise_in_domain0 – max_body_size – config_update –
    Returns: |

  `check_asset_in_response`(query_entry)

    (internal use) Check asset in the transaction

    Parameters: | query_entry –
    Returns: |

  `distribute_transaction_to_gather_signatures`(asset_group_id, dat)

    Request to distribute sign_request to users

    Parameters: | asset_group_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`(asset_group_id, txdata, asset_files, no_network_put=False)

    Insert transaction into ledger subsystem

    Parameters: | asset_group_id – asset_group_id to insert into 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`(asset_group_id, user_id)

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

  `search_asset_by_asid`(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: | 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`(asset_group_id, txid, source_id, query_id)

    Search transaction_data by transaction_id

    Parameters: | asset_group_id – asset_group_id to search in txid – transaction_id source_id – the user_id of the sender query_id –
    Returns: | response data including transaction_data

  `search_transaction_by_userid_locally`(asset_group_id, user_id, source_id, query_id)

    Local search a latest transaction that includes the asset owned by the specified user_id TODO: need to support search it within the domain :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`(asset_group_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)

    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, asgid, dstid, qid)

  (internal use) Create a base structure of message

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