ledger_subsystem 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.

LedgerSubsystem(config[, enabled, dbtype, ...]) Abstraction of an underlying ledger subsystem that is typically a blockchain.
class ledger_subsystem.LedgerSubsystem(config, enabled=False, dbtype='sqlite', loglevel='all', logname=None)[source]

Bases: object

Abstraction of an underlying ledger subsystem that is typically a blockchain. This takes one transaction each to record and verifies its existence. It forms some Merkle trees of transaction IDs, and writes their root digests only to the underlying ledger.

append_msg(msg)[source]
check_table_existence(dbname, name)[source]
close_db(dbname)[source]
close_merkle_tree(jTemp)[source]
create_table_in_db(dbname, tbl, tbl_definition, primary_keys=[], indices=[])[source]
disable()[source]

Disables communication with the underlying ledger.

Returns:
enable()[source]

Enables communication with the underlying ledger.

Returns:
exec_sql(dbname, sql, *dat)[source]
exec_sql_fetchone(dbname, sql, *dat)[source]
get_merkle_base(digest)[source]
open_db(dbname)[source]
register_transaction(asset_group_id, transaction_id)[source]

Registers a transaction.

Parameters:
  • asset_group_id – asset group
  • transaction_id – transaction to register
Returns:

subsystem_loop()[source]
subsystem_timer()[source]
verify_digest(digest, dic)[source]
verify_transaction(asset_group_id, transaction_id)[source]

Verifies whether the specified transaction is registered or not.

Parameters:
  • asset_group_id – asset group
  • transaction_id – transaction to verify its existence
Returns:

dictionary containing the result (and a Merkle subtree)

write_branch(digest=None, left=None, right=None)[source]
write_leaf(jTemp, digest=None, left=None, right=None)[source]
write_merkle_root(root)[source]
write_root(root=None, spec=None)[source]
class ledger_subsystem.Queue[source]

Bases: object

append_msg(msg)[source]
wait_msg(flash_others=False)[source]