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
def _create_state(self, name: str) -> PruningState: storage_name = getattr(self.config, "{}StateStorage".format(name)) db_name = getattr(self.config, "{}StateDbName".format(name)) if self.data_location is not None: return PruningState( initKeyValueStorage(storage_name, self.data_location, db_name, db_config=self.config.db_state_config)) else: return PruningState(KeyValueStorageInMemory())
def nym_handler(tconf): data_manager = DatabaseManager() handler = NymHandler(tconf, data_manager) state = PruningState(KeyValueStorageInMemory()) data_manager.register_new_database(handler.ledger_id, FakeSomething(), state) return handler
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
def loadState(self): return PruningState( initKeyValueStorage( self.config.poolStateStorage, self.node.dataLocation, self.config.poolStateDbName) )
def fees_authorizer(fees): authorizer = FeesAuthorizer( config_state=PruningState(KeyValueStorageInMemory()), utxo_cache=UTXOCache(KeyValueStorageInMemory())) authorizer.calculate_fees_from_req = lambda *args, **kwargs: fees.get( NYM_FEES_ALIAS) return authorizer
def node_handler(): data_manager = DatabaseManager() bls = FakeSomething() handler = NodeHandler(data_manager, bls) state = PruningState(KeyValueStorageInMemory()) data_manager.register_new_database(handler.ledger_id, FakeSomething(), state) return handler
def init_config_state(self): return PruningState( initKeyValueStorage( self.node.config.configStateStorage, self.node.dataLocation, self.node.config.configStateDbName, db_config=self.node.config.db_state_config) )
def state(request, tmpdir_factory) -> State: if request.param == 'memory': db = KeyValueStorageInMemory() if request.param == 'leveldb': db = KeyValueStorageLeveldb(tmpdir_factory.mktemp('').strpath, 'some_db') state = PruningState(db) yield state state.close()
def config_state(constraint_serializer): state = PruningState(KeyValueStorageInMemory()) Node.add_auth_rules_to_config_state(state=state, auth_map=auth_map, serializer=constraint_serializer) Node.add_auth_rules_to_config_state(state=state, auth_map=anyone_can_write_map, serializer=constraint_serializer) return state
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
def txn_author_agreement_aml_handler(tconf, domain_state): data_manager = DatabaseManager() handler = TxnAuthorAgreementAmlHandler(data_manager, FakeSomething()) state = PruningState(KeyValueStorageInMemory()) data_manager.register_new_database(handler.ledger_id, FakeSomething(), state) data_manager.register_new_database(DOMAIN_LEDGER_ID, FakeSomething(), domain_state) return handler
def ledgers_freeze_handler(tconf, domain_state, audit_ledger): data_manager = DatabaseManager() handler = LedgersFreezeHandler(data_manager) state = PruningState(KeyValueStorageInMemory()) data_manager.register_new_database(handler.ledger_id, FakeSomething(), state) data_manager.register_new_database(DOMAIN_LEDGER_ID, FakeSomething(), domain_state) data_manager.register_new_database(AUDIT_LEDGER_ID, audit_ledger) return handler
def request_handler(bls_store): state = PruningState(KeyValueStorageInMemory()) cache = IdrCache('Cache', KeyValueStorageInMemory()) attr_store = AttributeStore(KeyValueStorageInMemory()) return DomainReqHandler(ledger=None, state=state, requestProcessor=None, idrCache=cache, attributeStore=attr_store, bls_store=bls_store)
def database_manager(tdir_for_func): db = DatabaseManager() db.register_new_database( LEDGER_ID, Ledger(CompactMerkleTree(), dataDir=tdir_for_func), PruningState(KeyValueStorageRocksdb(tdir_for_func, 'kv1'))) db.register_new_store( TS_LABEL, StateTsDbStorage('test', {1: KeyValueStorageRocksdb(tdir_for_func, 'kv2')})) return db
def request_handler(bls_store): state = PruningState(KeyValueStorageInMemory()) config_state = PruningState(KeyValueStorageInMemory()) state_serializer = ConstraintsSerializer(domain_state_serializer) cache = IdrCache('Cache', KeyValueStorageInMemory()) attr_store = AttributeStore(KeyValueStorageInMemory()) write_req_validator = WriteRequestValidator( config=FakeSomething(authPolicy=CONFIG_LEDGER_AUTH_POLICY), auth_map=auth_map, cache=cache, config_state=config_state, state_serializer=state_serializer) return DomainReqHandler(ledger=None, state=state, config=None, requestProcessor=None, idrCache=cache, attributeStore=attr_store, bls_store=bls_store, write_req_validator=write_req_validator, ts_store=None)
def config_state(): return PruningState(KeyValueStorageInMemory())
def domain_state(tconf): return PruningState(KeyValueStorageInMemory())
def state2(db) -> State: state = PruningState(db) yield state state.close()
def pool_state(): return PruningState(KeyValueStorageInMemory())
def get_token_state(data_dir, name, config): return PruningState(initKeyValueStorage( config.tokenStateStorage, data_dir, name))
def state2(tempdir) -> State: global i state = PruningState( KeyValueStorageLeveldb(os.path.join(tempdir, 'kv2{}'.format(i)))) yield state state.close()
def get_auction_state(data_dir, name, config): return PruningState( initKeyValueStorage(config.auctionStateStorage, data_dir, name))
def state(tempdir) -> State: global i state = PruningState(KeyValueStorageLeveldb(tempdir, 'kv{}'.format(i))) yield state state.close()
def state2() -> State: state = PruningState(KeyValueStorageInMemory()) yield state state.close()
def reset_state(db_manager, lid): db_manager.databases[lid].state = PruningState(KeyValueStorageInMemory()) db_manager._init_db_list() return db_manager
def init_contract_state(node): return PruningState( initKeyValueStorage(node.config.contractStateStorage, node.dataLocation, node.config.contractStateDbName, db_config=node.config.db_state_config))
def get_graphchain_state(data_dir, name, config): logger.info("Creating LEI state with name '{}' in the '{}' dir and storage type equal to '{}'." .format(name, data_dir, config.graphchainStateStorage)) return PruningState(initKeyValueStorage(config.graphchainStateStorage, data_dir, name))