mirror of
https://github.com/romanz/electrs.git
synced 2024-11-19 09:54:09 +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"]
|
keywords = ["bitcoin", "electrum", "server", "index", "database"]
|
||||||
documentation = "https://docs.rs/electrs/"
|
documentation = "https://docs.rs/electrs/"
|
||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
|
edition = "2018"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
arrayref = "0.3"
|
arrayref = "0.3"
|
||||||
|
@ -1,9 +1,7 @@
|
|||||||
use bitcoin::util::hash::Sha256dHash;
|
use bitcoin::util::hash::Sha256dHash;
|
||||||
use std::sync::{Arc, Mutex};
|
use std::sync::{Arc, Mutex};
|
||||||
|
|
||||||
use {daemon, index, signal::Waiter, store};
|
use crate::{daemon, errors::*, index, signal::Waiter, store};
|
||||||
|
|
||||||
use errors::*;
|
|
||||||
|
|
||||||
pub struct App {
|
pub struct App {
|
||||||
store: store::DBStore,
|
store: store::DBStore,
|
||||||
|
13
src/bulk.rs
13
src/bulk.rs
@ -12,13 +12,12 @@ use std::sync::{
|
|||||||
};
|
};
|
||||||
use std::thread;
|
use std::thread;
|
||||||
|
|
||||||
use daemon::Daemon;
|
use crate::daemon::Daemon;
|
||||||
use index::{index_block, last_indexed_block, read_indexed_blockhashes};
|
use crate::errors::*;
|
||||||
use metrics::{CounterVec, Histogram, HistogramOpts, HistogramVec, MetricOpts, Metrics};
|
use crate::index::{index_block, last_indexed_block, read_indexed_blockhashes};
|
||||||
use store::{DBStore, Row, WriteStore};
|
use crate::metrics::{CounterVec, Histogram, HistogramOpts, HistogramVec, MetricOpts, Metrics};
|
||||||
use util::{spawn_thread, HeaderList, SyncChannel};
|
use crate::store::{DBStore, Row, WriteStore};
|
||||||
|
use crate::util::{spawn_thread, HeaderList, SyncChannel};
|
||||||
use errors::*;
|
|
||||||
|
|
||||||
struct Parser {
|
struct Parser {
|
||||||
magic: u32,
|
magic: u32,
|
||||||
|
@ -8,9 +8,8 @@ use std::path::{Path, PathBuf};
|
|||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use stderrlog;
|
use stderrlog;
|
||||||
|
|
||||||
use daemon::CookieGetter;
|
use crate::daemon::CookieGetter;
|
||||||
|
use crate::errors::*;
|
||||||
use errors::*;
|
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct Config {
|
pub struct Config {
|
||||||
|
@ -15,11 +15,10 @@ use std::path::PathBuf;
|
|||||||
use std::sync::{Arc, Mutex};
|
use std::sync::{Arc, Mutex};
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
|
|
||||||
use metrics::{HistogramOpts, HistogramVec, Metrics};
|
use crate::errors::*;
|
||||||
use signal::Waiter;
|
use crate::metrics::{HistogramOpts, HistogramVec, Metrics};
|
||||||
use util::HeaderList;
|
use crate::signal::Waiter;
|
||||||
|
use crate::util::HeaderList;
|
||||||
use errors::*;
|
|
||||||
|
|
||||||
fn parse_hash(value: &Value) -> Result<Sha256dHash> {
|
fn parse_hash(value: &Value) -> Result<Sha256dHash> {
|
||||||
Ok(Sha256dHash::from_hex(
|
Ok(Sha256dHash::from_hex(
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
use store::{ReadStore, Row, WriteStore};
|
use crate::store::{ReadStore, Row, WriteStore};
|
||||||
use util::Bytes;
|
use crate::util::Bytes;
|
||||||
|
|
||||||
pub struct FakeStore;
|
pub struct FakeStore;
|
||||||
|
|
||||||
@ -21,8 +21,8 @@ impl WriteStore for FakeStore {
|
|||||||
mod tests {
|
mod tests {
|
||||||
#[test]
|
#[test]
|
||||||
fn test_fakestore() {
|
fn test_fakestore() {
|
||||||
use fake;
|
use crate::fake;
|
||||||
use store::{ReadStore, Row, WriteStore};
|
use crate::store::{ReadStore, Row, WriteStore};
|
||||||
|
|
||||||
let store = fake::FakeStore {};
|
let store = fake::FakeStore {};
|
||||||
store.write(vec![Row {
|
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::iter::FromIterator;
|
||||||
use std::sync::RwLock;
|
use std::sync::RwLock;
|
||||||
|
|
||||||
use daemon::Daemon;
|
use crate::daemon::Daemon;
|
||||||
use metrics::{Counter, Gauge, HistogramOpts, HistogramTimer, HistogramVec, MetricOpts, Metrics};
|
use crate::errors::*;
|
||||||
use signal::Waiter;
|
use crate::metrics::{
|
||||||
use store::{ReadStore, Row, WriteStore};
|
Counter, Gauge, HistogramOpts, HistogramTimer, HistogramVec, MetricOpts, Metrics,
|
||||||
use util::{
|
};
|
||||||
|
use crate::signal::Waiter;
|
||||||
|
use crate::store::{ReadStore, Row, WriteStore};
|
||||||
|
use crate::util::{
|
||||||
full_hash, hash_prefix, spawn_thread, Bytes, FullHash, HashPrefix, HeaderEntry, HeaderList,
|
full_hash, hash_prefix, spawn_thread, Bytes, FullHash, HashPrefix, HeaderEntry, HeaderList,
|
||||||
HeaderMap, SyncChannel, HASH_PREFIX_LEN,
|
HeaderMap, SyncChannel, HASH_PREFIX_LEN,
|
||||||
};
|
};
|
||||||
|
|
||||||
use errors::*;
|
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize)]
|
#[derive(Serialize, Deserialize)]
|
||||||
pub struct TxInKey {
|
pub struct TxInKey {
|
||||||
pub code: u8,
|
pub code: u8,
|
||||||
|
20
src/lib.rs
20
src/lib.rs
@ -1,25 +1,5 @@
|
|||||||
#![recursion_limit = "1024"]
|
#![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]
|
#[macro_use]
|
||||||
extern crate chan;
|
extern crate chan;
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
|
@ -6,13 +6,14 @@ use std::iter::FromIterator;
|
|||||||
use std::ops::Bound;
|
use std::ops::Bound;
|
||||||
use std::sync::Mutex;
|
use std::sync::Mutex;
|
||||||
|
|
||||||
use daemon::{Daemon, MempoolEntry};
|
use crate::daemon::{Daemon, MempoolEntry};
|
||||||
use index::index_transaction;
|
use crate::errors::*;
|
||||||
use metrics::{Gauge, GaugeVec, HistogramOpts, HistogramTimer, HistogramVec, MetricOpts, Metrics};
|
use crate::index::index_transaction;
|
||||||
use store::{ReadStore, Row};
|
use crate::metrics::{
|
||||||
use util::Bytes;
|
Gauge, GaugeVec, HistogramOpts, HistogramTimer, HistogramVec, MetricOpts, Metrics,
|
||||||
|
};
|
||||||
use errors::*;
|
use crate::store::{ReadStore, Row};
|
||||||
|
use crate::util::Bytes;
|
||||||
|
|
||||||
const VSIZE_BIN_WIDTH: u32 = 100_000; // in vbytes
|
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,
|
IntCounterVec as CounterVec, IntGauge as Gauge, Opts as MetricOpts,
|
||||||
};
|
};
|
||||||
|
|
||||||
use util::spawn_thread;
|
use crate::errors::*;
|
||||||
|
use crate::util::spawn_thread;
|
||||||
use errors::*;
|
|
||||||
|
|
||||||
pub struct Metrics {
|
pub struct Metrics {
|
||||||
reg: prometheus::Registry,
|
reg: prometheus::Registry,
|
||||||
|
@ -11,7 +11,7 @@ use std::sync::mpsc::Sender;
|
|||||||
use std::thread;
|
use std::thread;
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
|
|
||||||
use util;
|
use crate::util;
|
||||||
|
|
||||||
fn connect() -> Result<Socket, Error> {
|
fn connect() -> Result<Socket, Error> {
|
||||||
let mut sock = Socket::new(Network::Bitcoin);
|
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::digest::Digest;
|
||||||
use crypto::sha2::Sha256;
|
use crypto::sha2::Sha256;
|
||||||
use lru::LruCache;
|
use lru::LruCache;
|
||||||
|
use serde_json::Value;
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use std::sync::{Arc, Mutex, RwLock};
|
use std::sync::{Arc, Mutex, RwLock};
|
||||||
|
|
||||||
use app::App;
|
use crate::app::App;
|
||||||
use index::{compute_script_hash, TxInRow, TxOutRow, TxRow};
|
use crate::errors::*;
|
||||||
use mempool::Tracker;
|
use crate::index::{compute_script_hash, TxInRow, TxOutRow, TxRow};
|
||||||
use metrics::Metrics;
|
use crate::mempool::Tracker;
|
||||||
use serde_json::Value;
|
use crate::metrics::Metrics;
|
||||||
use store::{ReadStore, Row};
|
use crate::store::{ReadStore, Row};
|
||||||
use util::{FullHash, HashPrefix, HeaderEntry};
|
use crate::util::{FullHash, HashPrefix, HeaderEntry};
|
||||||
|
|
||||||
use errors::*;
|
|
||||||
|
|
||||||
pub struct FundingOutput {
|
pub struct FundingOutput {
|
||||||
pub txn_id: Sha256dHash,
|
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::sync::{Arc, Mutex};
|
||||||
use std::thread;
|
use std::thread;
|
||||||
|
|
||||||
use index::compute_script_hash;
|
use crate::errors::*;
|
||||||
use metrics::{Gauge, HistogramOpts, HistogramVec, MetricOpts, Metrics};
|
use crate::index::compute_script_hash;
|
||||||
use query::{Query, Status};
|
use crate::metrics::{Gauge, HistogramOpts, HistogramVec, MetricOpts, Metrics};
|
||||||
use util::{spawn_thread, Channel, HeaderEntry, SyncChannel};
|
use crate::query::{Query, Status};
|
||||||
|
use crate::util::{spawn_thread, Channel, HeaderEntry, SyncChannel};
|
||||||
use errors::*;
|
|
||||||
|
|
||||||
// TODO: Sha256dHash should be a generic hash-container (since script hash is single SHA256)
|
// TODO: Sha256dHash should be a generic hash-container (since script hash is single SHA256)
|
||||||
fn hash_from_value(val: Option<&Value>) -> Result<Sha256dHash> {
|
fn hash_from_value(val: Option<&Value>) -> Result<Sha256dHash> {
|
||||||
|
@ -2,7 +2,7 @@ use chan;
|
|||||||
use chan_signal;
|
use chan_signal;
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
|
|
||||||
use errors::*;
|
use crate::errors::*;
|
||||||
|
|
||||||
#[derive(Clone)] // so multiple threads could wait on signals
|
#[derive(Clone)] // so multiple threads could wait on signals
|
||||||
pub struct Waiter {
|
pub struct Waiter {
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
use rocksdb;
|
use rocksdb;
|
||||||
|
|
||||||
use std::path::{Path, PathBuf};
|
use std::path::{Path, PathBuf};
|
||||||
|
|
||||||
use util::Bytes;
|
use crate::util::Bytes;
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct Row {
|
pub struct Row {
|
||||||
|
Loading…
Reference in New Issue
Block a user