Пример #1
0
def hashStore(request, tmpdir_factory):
    if request.param == HS_MEMORY:
        yield MemoryHashStore()
    else:
        hs = DbHashStore(tmpdir_factory.mktemp('').strpath, db_type=request.param)
        hs.reset()
        yield hs
        hs.close()
Пример #2
0
def initHashStore(data_dir, name, config=None) -> HashStore:
    """
    Create and return a hashStore implementation based on configuration
    """
    config = config or getConfig()
    hsConfig = config.hashStore['type'].lower()
    if hsConfig == HS_FILE:
        return FileHashStore(dataDir=data_dir, fileNamePrefix=name)
    elif hsConfig == HS_LEVELDB or hsConfig == HS_ROCKSDB:
        return DbHashStore(dataDir=data_dir,
                           fileNamePrefix=name,
                           db_type=hsConfig)
    else:
        return MemoryHashStore()
Пример #3
0
def testInvalidDBType(tmpdir_factory):
    HS_WRONGDB = 'somedb'
    assert HS_WRONGDB not in (HS_LEVELDB, HS_ROCKSDB)
    with pytest.raises(ValueError) as excinfo:
        DbHashStore('', db_type=HS_WRONGDB)
    assert "one of {}".format((HS_ROCKSDB, HS_LEVELDB)) in str(excinfo.value)
Пример #4
0
def hashStore(request, tmpdir_factory):
    hs = DbHashStore(tmpdir_factory.mktemp('').strpath, db_type=request.param)
    cleanup(hs)
    yield hs
    hs.close()
Пример #5
0
def get_auction_hash_store(data_dir):
    return DbHashStore(dataDir=data_dir,
                       fileNamePrefix='auction',
                       db_type=HS_LEVELDB)
Пример #6
0
def get_graphchain_hash_store(data_dir):
    logger.info("Creating LEI hash store in '{}'.".format(data_dir))

    return DbHashStore(dataDir=data_dir,
                       fileNamePrefix=GRAPHCHAIN_HASH_STORE_NAME,
                       db_type=HS_ROCKSDB)