pub fn create(path: PathBuf) -> Result<(), Error> {
        let env = Environment::new()
            .set_max_dbs(20)
            .set_map_size(MAX_LMDB_FILE_SIZE)
            .open(&path)
            .unwrap_or_else(|_| {
                panic!(
                    "Could not create environment for ledger_db. Check that path exists {:?}",
                    path
                )
            });

        let counts = env.create_db(Some(COUNTS_DB_NAME), DatabaseFlags::empty())?;
        env.create_db(Some(BLOCKS_DB_NAME), DatabaseFlags::empty())?;
        env.create_db(Some(BLOCK_CONTENTS_DB_NAME), DatabaseFlags::empty())?;
        env.create_db(Some(BLOCK_SIGNATURES_DB_NAME), DatabaseFlags::empty())?;
        env.create_db(Some(KEY_IMAGES_DB_NAME), DatabaseFlags::empty())?;
        env.create_db(Some(KEY_IMAGES_BY_BLOCK_DB_NAME), DatabaseFlags::empty())?;

        TxOutStore::create(&env)?;

        let mut db_transaction = env.begin_rw_txn()?;

        db_transaction.put(
            counts,
            &NUM_BLOCKS_KEY,
            &u64_to_key_bytes(0),
            WriteFlags::empty(),
        )?;

        db_transaction.commit()?;
        Ok(())
    }
/// Creates a fresh Ledger Database in the given path.
Creates a fresh Ledger Database in the given path.
Creates a fresh Ledger Database in the given path .
pub fn create(path: PathBuf) -> Result<(), Error> {
        let env = Environment::new()
            .set_max_dbs(20)
            .set_map_size(MAX_LMDB_FILE_SIZE)
            .open(&path)
            .unwrap_or_else(|_| {
                panic!(
                    "Could not create environment for ledger_db. Check that path exists {:?}",
                    path
                )
            });
        let counts = env.create_db(Some(COUNTS_DB_NAME), DatabaseFlags::empty())?;
        env.create_db(Some(BLOCKS_DB_NAME), DatabaseFlags::empty())?;
        env.create_db(Some(BLOCK_CONTENTS_DB_NAME), DatabaseFlags::empty())?;
        env.create_db(Some(BLOCK_SIGNATURES_DB_NAME), DatabaseFlags::empty())?;
        env.create_db(Some(KEY_IMAGES_DB_NAME), DatabaseFlags::empty())?;
        env.create_db(Some(KEY_IMAGES_BY_BLOCK_DB_NAME), DatabaseFlags::empty())?;
        TxOutStore::create(&env)?;
        let mut db_transaction = env.begin_rw_txn()?;
        db_transaction.put(
            counts,
            &NUM_BLOCKS_KEY,
            &u64_to_key_bytes(0),
            WriteFlags::empty(),
        )?;
        db_transaction.commit()?;
        Ok(())
    }
pub fn create ( path : PathBuf ) -> Result < ( ) , Error > { let env = Environment :: new ( ) . set_max_dbs ( 20 ) . set_map_size ( MAX_LMDB_FILE_SIZE ) . open ( & path ) . unwrap_or_else ( | _ | { panic ! ( " " path ) } ) ; let counts = env . create_db ( Some ( COUNTS_DB_NAME ) , DatabaseFlags :: empty ( ) ) ? ; env . create_db ( Some ( BLOCKS_DB_NAME ) , DatabaseFlags :: empty ( ) ) ? ; env . create_db ( Some ( BLOCK_CONTENTS_DB_NAME ) , DatabaseFlags :: empty ( ) ) ? ; env . create_db ( Some ( BLOCK_SIGNATURES_DB_NAME ) , DatabaseFlags :: empty ( ) ) ? ; env . create_db ( Some ( KEY_IMAGES_DB_NAME ) , DatabaseFlags :: empty ( ) ) ? ; env . create_db ( Some ( KEY_IMAGES_BY_BLOCK_DB_NAME ) , DatabaseFlags :: empty ( ) ) ? ; TxOutStore :: create ( & env ) ? ; let mut db_transaction = env . begin_rw_txn ( ) ? ; db_transaction . put ( counts , & NUM_BLOCKS_KEY , & u64_to_key_bytes ( 0 ) , WriteFlags :: empty ( ) , ) ? ; db_transaction . commit ( ) ? ; Ok ( ( ) ) }
Creates a fresh Ledger Database in the given path.
Creates a fresh Ledger Database in the given path .
path
PathBuf
path
PathBuf