mirror of
https://github.com/romanz/electrs.git
synced 2024-11-19 01:43:29 +01:00
Support Rust 2018 edition
Builds on Rust 1.31
This commit is contained in:
parent
0dae2f198a
commit
5f2d4289dc
@ -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"
|
||||
|
@ -1,9 +1,7 @@
|
||||
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,
|
||||
|
13
src/bulk.rs
13
src/bulk.rs
@ -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(
|
||||
|
@ -1,5 +1,5 @@
|
||||
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 {
|
||||
|
15
src/index.rs
15
src/index.rs
@ -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,
|
||||
|
20
src/lib.rs
20
src/lib.rs
@ -1,25 +1,5 @@
|
||||
#![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);
|
||||
|
17
src/query.rs
17
src/query.rs
@ -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,
|
||||
|
11
src/rpc.rs
11
src/rpc.rs
@ -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 {
|
||||
|
@ -1,8 +1,7 @@
|
||||
use rocksdb;
|
||||
|
||||
use std::path::{Path, PathBuf};
|
||||
|
||||
use util::Bytes;
|
||||
use crate::util::Bytes;
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct Row {
|
||||
|
Loading…
Reference in New Issue
Block a user