mirror of
https://github.com/alexgo-io/bitcoin-indexer.git
synced 2026-01-12 22:43:06 +08:00
fix: safer db open, dockerfile
This commit is contained in:
@@ -664,9 +664,15 @@ pub fn should_sync_hord_db(config: &Config, ctx: &Context) -> Result<Option<(u64
|
||||
}
|
||||
};
|
||||
|
||||
let start_block = {
|
||||
let blocks_db = open_readonly_hord_db_conn_rocks_db(&config.expected_cache_path(), &ctx)?;
|
||||
find_last_block_inserted(&blocks_db) as u64
|
||||
let start_block = match open_readonly_hord_db_conn_rocks_db(&config.expected_cache_path(), &ctx) {
|
||||
Ok(blocks_db) => find_last_block_inserted(&blocks_db) as u64,
|
||||
Err(err) => {
|
||||
warn!(
|
||||
ctx.expect_logger(),
|
||||
"{}", err
|
||||
);
|
||||
0
|
||||
}
|
||||
};
|
||||
|
||||
if start_block == 0 {
|
||||
|
||||
@@ -344,9 +344,10 @@ pub fn open_readonly_hord_db_conn_rocks_db(
|
||||
) -> Result<DB, String> {
|
||||
let path = get_default_hord_db_file_path_rocks_db(&base_dir);
|
||||
let mut opts = rocksdb::Options::default();
|
||||
opts.create_if_missing(true);
|
||||
opts.set_compression_type(rocksdb::DBCompressionType::Lz4);
|
||||
opts.set_max_open_files(1000);
|
||||
let db = DB::open_for_read_only(&opts, path, false).unwrap();
|
||||
let db = DB::open_for_read_only(&opts, path, false).map_err(|e| format!("unable to open blocks_db: {}", e.to_string()))?;
|
||||
Ok(db)
|
||||
}
|
||||
|
||||
@@ -359,7 +360,7 @@ pub fn open_readwrite_hord_db_conn_rocks_db(
|
||||
opts.create_if_missing(true);
|
||||
opts.set_compression_type(rocksdb::DBCompressionType::Lz4);
|
||||
opts.set_max_open_files(1000);
|
||||
let db = DB::open(&opts, path).unwrap();
|
||||
let db = DB::open(&opts, path).map_err(|e| format!("unable to open blocks_db: {}", e.to_string()))?;
|
||||
Ok(db)
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ FROM rust:bullseye as build
|
||||
|
||||
WORKDIR /src
|
||||
|
||||
RUN apt update && apt install -y ca-certificates pkg-config libssl-dev
|
||||
RUN apt update && apt install -y ca-certificates pkg-config libssl-dev libclang-11-dev
|
||||
|
||||
RUN rustup update 1.67.0 && rustup default 1.67.0
|
||||
|
||||
|
||||
Reference in New Issue
Block a user