mirror of
https://github.com/romanz/electrs.git
synced 2026-08-15 12:50:18 +02:00
Format code
This commit is contained in:
parent
3b591b8f79
commit
fe3364e9c6
4 changed files with 17 additions and 16 deletions
|
|
@ -24,13 +24,13 @@ use std::io::Write;
|
|||
use std::net::{IpAddr, Ipv4Addr, SocketAddr, TcpStream};
|
||||
use std::time::{Duration, Instant, SystemTime, UNIX_EPOCH};
|
||||
|
||||
use crate::connection::BlockSource;
|
||||
use crate::types::SerBlock;
|
||||
use crate::{
|
||||
chain::{Chain, NewHeader},
|
||||
config::ELECTRS_VERSION,
|
||||
metrics::{default_duration_buckets, default_size_buckets, Histogram, Metrics},
|
||||
};
|
||||
use crate::connection::BlockSource;
|
||||
|
||||
enum Request {
|
||||
GetNewHeaders(GetHeadersMessage),
|
||||
|
|
@ -411,7 +411,11 @@ impl BlockSource for Connection {
|
|||
self.get_new_headers(chain)
|
||||
}
|
||||
|
||||
fn for_blocks<'a>(&mut self, blockhashes: Vec<BlockHash>, func: Box<dyn FnMut(BlockHash, SerBlock) + 'a>) -> anyhow::Result<()> {
|
||||
fn for_blocks<'a>(
|
||||
&mut self,
|
||||
blockhashes: Vec<BlockHash>,
|
||||
func: Box<dyn FnMut(BlockHash, SerBlock) + 'a>,
|
||||
) -> anyhow::Result<()> {
|
||||
self.for_blocks(blockhashes, func)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -39,11 +39,7 @@ pub struct RestZmqBlockSource {
|
|||
}
|
||||
|
||||
impl RestZmqBlockSource {
|
||||
pub fn connect(
|
||||
rest_addr: SocketAddr,
|
||||
zmq_endpoint: &str,
|
||||
metrics: &Metrics,
|
||||
) -> Result<Self> {
|
||||
pub fn connect(rest_addr: SocketAddr, zmq_endpoint: &str, metrics: &Metrics) -> Result<Self> {
|
||||
// Verify REST is enabled.
|
||||
let mut conn = RestConn::connect(rest_addr)?;
|
||||
conn.get("/rest/chaininfo.json")
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ use std::fs::File;
|
|||
use std::io::Read;
|
||||
use std::path::Path;
|
||||
|
||||
use crate::connection::{make_p2p_connection, make_rpc_zmq_connection, BlockSource};
|
||||
use crate::{
|
||||
chain::{Chain, NewHeader},
|
||||
config::Config,
|
||||
|
|
@ -20,7 +21,6 @@ use crate::{
|
|||
signals::ExitFlag,
|
||||
types::SerBlock,
|
||||
};
|
||||
use crate::connection::{BlockSource, make_p2p_connection, make_rpc_zmq_connection};
|
||||
|
||||
enum PollResult {
|
||||
Done(Result<()>),
|
||||
|
|
@ -141,11 +141,7 @@ impl Daemon {
|
|||
|
||||
let source: Box<dyn BlockSource> = if let Some(ref zmq_ep) = config.daemon_zmq_addr {
|
||||
info!("using RPC+ZMQ block source (zmq_endpoint={})", zmq_ep);
|
||||
make_rpc_zmq_connection(
|
||||
config.daemon_rpc_addr,
|
||||
zmq_ep,
|
||||
metrics,
|
||||
)?
|
||||
make_rpc_zmq_connection(config.daemon_rpc_addr, zmq_ep, metrics)?
|
||||
} else {
|
||||
if !network_info.network_active {
|
||||
bail!("electrs requires active bitcoind p2p network (or use --zmq-endpoint)");
|
||||
|
|
@ -156,7 +152,10 @@ impl Daemon {
|
|||
|
||||
let source = Mutex::new(source);
|
||||
|
||||
Ok(Self { block_source: source, rpc })
|
||||
Ok(Self {
|
||||
block_source: source,
|
||||
rpc,
|
||||
})
|
||||
}
|
||||
|
||||
pub(crate) fn estimate_fee(&self, nblocks: u16) -> Result<Option<Amount>> {
|
||||
|
|
@ -309,7 +308,9 @@ impl Daemon {
|
|||
B: IntoIterator<Item = BlockHash>,
|
||||
F: FnMut(BlockHash, SerBlock) + 'a,
|
||||
{
|
||||
self.block_source.lock().for_blocks(blockhashes.into_iter().collect(), Box::new(func))
|
||||
self.block_source
|
||||
.lock()
|
||||
.for_blocks(blockhashes.into_iter().collect(), Box::new(func))
|
||||
}
|
||||
|
||||
pub(crate) fn new_block_notification(&self) -> Receiver<()> {
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ extern crate serde_derive;
|
|||
mod cache;
|
||||
mod chain;
|
||||
mod config;
|
||||
mod connection;
|
||||
mod daemon;
|
||||
mod db;
|
||||
mod electrum;
|
||||
|
|
@ -17,7 +18,6 @@ mod index;
|
|||
mod mempool;
|
||||
mod merkle;
|
||||
mod metrics;
|
||||
mod connection;
|
||||
mod server;
|
||||
mod signals;
|
||||
mod status;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue