Unverified Commit 5f2d4289 authored by Roman Zeyde's avatar Roman Zeyde
Browse files

Support Rust 2018 edition

Builds on Rust 1.31
parent 0dae2f19
......@@ -9,6 +9,7 @@ repository = "https://github.com/romanz/electrs"
keywords = ["bitcoin", "electrum", "server", "index", "database"]
documentation = "https://docs.rs/electrs/"
readme = "README.md"
edition = "2018"
[dependencies]
arrayref = "0.3"
......
use bitcoin::util::hash::Sha256dHash;
use std::sync::{Arc, Mutex};
use {daemon, index, signal::Waiter, store};
use errors::*;
use crate::{daemon, errors::*, index, signal::Waiter, store};
pub struct App {
store: store::DBStore,
......
......@@ -12,13 +12,12 @@ use std::sync::{
};
use std::thread;
use daemon::Daemon;
use index::{index_block, last_indexed_block, read_indexed_blockhashes};
use metrics::{CounterVec, Histogram, HistogramOpts, HistogramVec, MetricOpts, Metrics};
use store::{DBStore, Row, WriteStore};
use util::{spawn_thread, HeaderList, SyncChannel};
use errors::*;
use crate::daemon::Daemon;
use crate::errors::*;
use crate::index::{index_block, last_indexed_block, read_indexed_blockhashes};
use crate::metrics::{CounterVec, Histogram, HistogramOpts, HistogramVec, MetricOpts, Metrics};
use crate::store::{DBStore, Row, WriteStore};
use crate::util::{spawn_thread, HeaderList, SyncChannel};
struct Parser {
magic: u32,
......
......@@ -8,9 +8,8 @@ use std::path::{Path, PathBuf};
use std::sync::Arc;
use stderrlog;
use daemon::CookieGetter;
use errors::*;
use crate::daemon::CookieGetter;
use crate::errors::*;
#[derive(Debug)]
pub struct Config {
......
......@@ -15,11 +15,10 @@ use std::path::PathBuf;
use std::sync::{Arc, Mutex};
use std::time::Duration;
use metrics::{HistogramOpts, HistogramVec, Metrics};
use signal::Waiter;
use util::HeaderList;
use errors::*;
use crate::errors::*;
use crate::metrics::{HistogramOpts, HistogramVec, Metrics};
use crate::signal::Waiter;
use crate::util::HeaderList;
fn parse_hash(value: &Value) -> Result<Sha256dHash> {
Ok(Sha256dHash::from_hex(
......
use store::{ReadStore, Row, WriteStore};
use util::Bytes;
use crate::store::{ReadStore, Row, WriteStore};
use crate::util::Bytes;
pub struct FakeStore;
......@@ -21,8 +21,8 @@ impl WriteStore for FakeStore {
mod tests {
#[test]
fn test_fakestore() {
use fake;
use store::{ReadStore, Row, WriteStore};
use crate::fake;
use crate::store::{ReadStore, Row, WriteStore};
let store = fake::FakeStore {};
store.write(vec![Row {
......
......@@ -10,17 +10,18 @@ use std::collections::{HashMap, HashSet};
use std::iter::FromIterator;
use std::sync::RwLock;
use daemon::Daemon;
use metrics::{Counter, Gauge, HistogramOpts, HistogramTimer, HistogramVec, MetricOpts, Metrics};
use signal::Waiter;
use store::{ReadStore, Row, WriteStore};
use util::{
use crate::daemon::Daemon;
use crate::errors::*;
use crate::metrics::{
Counter, Gauge, HistogramOpts, HistogramTimer, HistogramVec, MetricOpts, Metrics,
};
use crate::signal::Waiter;
use crate::store::{ReadStore, Row, WriteStore};
use crate::util::{
full_hash, hash_prefix, spawn_thread, Bytes, FullHash, HashPrefix, HeaderEntry, HeaderList,
HeaderMap, SyncChannel, HASH_PREFIX_LEN,
};
use errors::*;
#[derive(Serialize, Deserialize)]
pub struct TxInKey {
pub code: u8,
......
#![recursion_limit = "1024"]
extern crate base64;
extern crate bincode;
extern crate bitcoin;
extern crate chan_signal;
extern crate crypto;
extern crate dirs;
extern crate glob;
extern crate hex;
extern crate libc;
extern crate lru;
extern crate num_cpus;
extern crate page_size;
extern crate prometheus;
extern crate rocksdb;
extern crate serde;
extern crate stderrlog;
extern crate sysconf;
extern crate time;
extern crate tiny_http;
#[macro_use]
extern crate chan;
#[macro_use]
......
......@@ -6,13 +6,14 @@ use std::iter::FromIterator;
use std::ops::Bound;
use std::sync::Mutex;
use daemon::{Daemon, MempoolEntry};
use index::index_transaction;
use metrics::{Gauge, GaugeVec, HistogramOpts, HistogramTimer, HistogramVec, MetricOpts, Metrics};
use store::{ReadStore, Row};
use util::Bytes;
use errors::*;
use crate::daemon::{Daemon, MempoolEntry};
use crate::errors::*;
use crate::index::index_transaction;
use crate::metrics::{
Gauge, GaugeVec, HistogramOpts, HistogramTimer, HistogramVec, MetricOpts, Metrics,
};
use crate::store::{ReadStore, Row};
use crate::util::Bytes;
const VSIZE_BIN_WIDTH: u32 = 100_000; // in vbytes
......
......@@ -13,9 +13,8 @@ pub use prometheus::{
IntCounterVec as CounterVec, IntGauge as Gauge, Opts as MetricOpts,
};
use util::spawn_thread;
use errors::*;
use crate::errors::*;
use crate::util::spawn_thread;
pub struct Metrics {
reg: prometheus::Registry,
......
......@@ -11,7 +11,7 @@ use std::sync::mpsc::Sender;
use std::thread;
use std::time::Duration;
use util;
use crate::util;
fn connect() -> Result<Socket, Error> {
let mut sock = Socket::new(Network::Bitcoin);
......
......@@ -4,18 +4,17 @@ use bitcoin::util::hash::Sha256dHash;
use crypto::digest::Digest;
use crypto::sha2::Sha256;
use lru::LruCache;
use serde_json::Value;
use std::collections::HashMap;
use std::sync::{Arc, Mutex, RwLock};
use app::App;
use index::{compute_script_hash, TxInRow, TxOutRow, TxRow};
use mempool::Tracker;
use metrics::Metrics;
use serde_json::Value;
use store::{ReadStore, Row};
use util::{FullHash, HashPrefix, HeaderEntry};
use errors::*;
use crate::app::App;
use crate::errors::*;
use crate::index::{compute_script_hash, TxInRow, TxOutRow, TxRow};
use crate::mempool::Tracker;
use crate::metrics::Metrics;
use crate::store::{ReadStore, Row};
use crate::util::{FullHash, HashPrefix, HeaderEntry};
pub struct FundingOutput {
pub txn_id: Sha256dHash,
......
......@@ -13,12 +13,11 @@ use std::sync::mpsc::{Sender, SyncSender, TrySendError};
use std::sync::{Arc, Mutex};
use std::thread;
use index::compute_script_hash;
use metrics::{Gauge, HistogramOpts, HistogramVec, MetricOpts, Metrics};
use query::{Query, Status};
use util::{spawn_thread, Channel, HeaderEntry, SyncChannel};
use errors::*;
use crate::errors::*;
use crate::index::compute_script_hash;
use crate::metrics::{Gauge, HistogramOpts, HistogramVec, MetricOpts, Metrics};
use crate::query::{Query, Status};
use crate::util::{spawn_thread, Channel, HeaderEntry, SyncChannel};
// TODO: Sha256dHash should be a generic hash-container (since script hash is single SHA256)
fn hash_from_value(val: Option<&Value>) -> Result<Sha256dHash> {
......
......@@ -2,7 +2,7 @@ use chan;
use chan_signal;
use std::time::Duration;
use errors::*;
use crate::errors::*;
#[derive(Clone)] // so multiple threads could wait on signals
pub struct Waiter {
......
use rocksdb;
use std::path::{Path, PathBuf};
use util::Bytes;
use crate::util::Bytes;
#[derive(Clone)]
pub struct Row {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment