1
0
mirror of https://github.com/romanz/electrs.git synced 2024-11-19 01:43:29 +01:00

Move extern crate to main.rs

This commit is contained in:
Roman Zeyde 2018-04-11 12:44:44 +03:00
parent 17ea973c02
commit 09d4df49f3
No known key found for this signature in database
GPG Key ID: 87CAE5FA46917CBB
5 changed files with 19 additions and 25 deletions

View File

@ -1,12 +1,10 @@
extern crate itertools;
extern crate reqwest;
use bitcoin::blockdata::block::BlockHeader;
use bitcoin::network::encodable::ConsensusDecodable;
use bitcoin::network::serialize::BitcoinHash;
use bitcoin::network::serialize::RawDecoder;
use bitcoin::util::hash::Sha256dHash;
use self::itertools::enumerate;
use itertools::enumerate;
use reqwest;
use std::collections::{HashMap, VecDeque};
use std::io::Cursor;

View File

@ -1,11 +1,15 @@
#[macro_use]
extern crate log;
extern crate bitcoin;
extern crate byteorder;
extern crate crypto;
extern crate itertools;
extern crate reqwest;
extern crate rocksdb;
extern crate simple_logger;
extern crate time;
extern crate zmq;
#[macro_use]
extern crate log;
mod daemon;
mod store;

View File

@ -1,20 +1,14 @@
extern crate bitcoin;
extern crate byteorder;
extern crate crypto;
extern crate rocksdb;
extern crate time;
use self::rocksdb::{DBCompactionStyle, DBCompressionType, WriteBatch, WriteOptions, DB};
use bitcoin::blockdata::block::BlockHeader;
use bitcoin::network::serialize::deserialize;
use rocksdb;
use std::char::from_digit;
use std::collections::HashMap;
use self::time::{Duration, PreciseTime};
use time::{Duration, PreciseTime};
use Bytes;
pub struct Store {
db: DB,
db: rocksdb::DB,
rows: Vec<Row>,
start: PreciseTime,
}
@ -42,10 +36,10 @@ impl Store {
pub fn open(path: &str, opts: StoreOptions) -> Store {
let mut db_opts = rocksdb::Options::default();
db_opts.create_if_missing(true);
db_opts.set_compaction_style(DBCompactionStyle::Level);
db_opts.set_compaction_style(rocksdb::DBCompactionStyle::Level);
db_opts.set_max_open_files(256);
db_opts.set_use_fsync(false);
db_opts.set_compression_type(DBCompressionType::Snappy);
db_opts.set_compression_type(rocksdb::DBCompressionType::Snappy);
db_opts.set_target_file_size_base(128 << 20);
db_opts.set_write_buffer_size(256 << 20);
// db_opts.set_compaction_readahead_size(2 << 20);
@ -55,7 +49,7 @@ impl Store {
block_opts.set_block_size(256 << 10);
info!("opening {}", path);
Store {
db: DB::open(&db_opts, &path).unwrap(),
db: rocksdb::DB::open(&db_opts, &path).unwrap(),
rows: vec![],
start: PreciseTime::now(),
}
@ -71,11 +65,11 @@ impl Store {
}
pub fn flush(&mut self) {
let mut batch = WriteBatch::default();
let mut batch = rocksdb::WriteBatch::default();
for row in &self.rows {
batch.put(row.key.as_slice(), row.value.as_slice()).unwrap();
}
let mut opts = WriteOptions::new();
let mut opts = rocksdb::WriteOptions::new();
opts.set_sync(true);
self.db.write_opt(batch, &opts).unwrap();
self.rows.clear();

View File

@ -1,8 +1,6 @@
extern crate time;
use std::fmt::Write;
use std::collections::HashMap;
use self::time::{Duration, PreciseTime};
use time::{Duration, PreciseTime};
pub struct Timer {
durations: HashMap<String, Duration>,

View File

@ -1,4 +1,4 @@
extern crate zmq;
use zmq;
use Bytes;