Move extern crate
to main.rs
This commit is contained in:
parent
17ea973c02
commit
09d4df49f3
|
@ -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;
|
||||
|
||||
|
|
10
src/main.rs
10
src/main.rs
|
@ -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;
|
||||
|
|
22
src/store.rs
22
src/store.rs
|
@ -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();
|
||||
|
|
|
@ -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>,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
extern crate zmq;
|
||||
use zmq;
|
||||
|
||||
use Bytes;
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user