Example #1
0
def db_manager(tconf, tdir, idr_cache):
    db_manager = DatabaseManager()

    db_manager.register_new_store(IDR_CACHE_LABEL, idr_cache)
    db_manager.register_new_database(DOMAIN_LEDGER_ID, get_fake_ledger(),
                                     PruningState(KeyValueStorageInMemory()))
    db_manager.register_new_database(CONFIG_LEDGER_ID, get_fake_ledger(),
                                     PruningState(KeyValueStorageInMemory()))
    db_manager.register_new_database(POOL_LEDGER_ID, get_fake_ledger(),
                                     PruningState(KeyValueStorageInMemory()))
    return db_manager
Example #2
0
def db_manager(tconf):
    _db_manager = DatabaseManager()
    storage = initKeyValueStorage(
        KeyValueStorageType.Memory,
        None,
        "tokenInMemoryStore",
        txn_serializer=serialization.multi_sig_store_serializer)
    ledger = get_fake_ledger()

    def commit_txns(count):
        ledger.committed_root_hash = ledger.uncommitted_root_hash
        return None, [1]

    ledger.commitTxns = commit_txns
    ledger.root_hash = txn_root_serializer.serialize("1")
    ledger.uncommitted_root_hash = "1"
    ledger.uncommitted_size = 1
    ledger.size = 0
    ledger.discardTxns = lambda x: None
    ledger.committed_root_hash = "-1"
    ledger.append_txns_metadata = lambda txns, txn_time: [
        append_txn_metadata(txn, 2, txn_time, 2) for txn in txns
    ]
    ledger.appendTxns = lambda x: (None, x)
    _db_manager.register_new_database(TOKEN_LEDGER_ID, ledger,
                                      PruningState(storage))
    return _db_manager
Example #3
0
def db_manager_with_config(db_manager, utxo_cache):
    storage = initKeyValueStorage(KeyValueStorageType.Memory,
                                  None,
                                  "configInMemoryStore",
                                  txn_serializer=in_memory_serializer)
    ledger = get_fake_ledger()
    db_manager.register_new_database(CONFIG_LEDGER_ID, ledger,
                                     PruningState(storage))
    return db_manager
Example #4
0
def db_manager(tconf, tdir):
    db_manager = DatabaseManager()
    name = 'name'
    idr_cache = IdrCache(
        name,
        initKeyValueStorage(KeyValueStorageType.Rocksdb,
                            tdir,
                            tconf.idrCacheDbName,
                            db_config=tconf.db_idr_cache_db_config))
    db_manager.register_new_store('idr', idr_cache)
    db_manager.register_new_database(DOMAIN_LEDGER_ID, get_fake_ledger(),
                                     State())
    return db_manager
Example #5
0
def db_manager(tconf, tdir):
    db_manager = DatabaseManager()

    state = State()
    state.txn_list = {}
    state.get = lambda key, isCommitted=True: state.txn_list.get(key, None)
    state.set = lambda key, value: state.txn_list.update({key: value})

    name = 'name'
    idr_cache = IdrCache(name,
                         initKeyValueStorage(KeyValueStorageType.Rocksdb,
                                             tdir,
                                             tconf.idrCacheDbName,
                                             db_config=tconf.db_idr_cache_db_config))
    db_manager.register_new_store(IDR_CACHE_LABEL, idr_cache)
    db_manager.register_new_database(DOMAIN_LEDGER_ID, get_fake_ledger(), state)
    return db_manager