}
pub(crate) struct GossipRouter {
- native_router: P2PGossipSync<Arc<NetworkGraph<Arc<TestLogger>>>, GossipChainAccess, Arc<TestLogger>>,
+ native_router: P2PGossipSync<Arc<NetworkGraph<TestLogger>>, GossipChainAccess, TestLogger>,
pub(crate) counter: RwLock<GossipCounter>,
sender: mpsc::Sender<GossipMessage>,
}
impl GossipRouter {
- pub(crate) fn new(network_graph: Arc<NetworkGraph<Arc<TestLogger>>>, sender: mpsc::Sender<GossipMessage>) -> Self {
+ pub(crate) fn new(network_graph: Arc<NetworkGraph<TestLogger>>, sender: mpsc::Sender<GossipMessage>) -> Self {
Self {
- native_router: P2PGossipSync::new(network_graph, Some(Arc::new(ChainVerifier::new())),
- Arc::new(TestLogger::new())),
+ native_router: P2PGossipSync::new(network_graph, Some(Arc::new(ChainVerifier::new())), TestLogger::new()),
counter: RwLock::new(GossipCounter::new()),
sender
}
mod verifier;
pub struct RapidSyncProcessor {
- network_graph: Arc<NetworkGraph<Arc<TestLogger>>>,
+ network_graph: Arc<NetworkGraph<TestLogger>>,
pub initial_sync_complete: Arc<AtomicBool>,
}
pub fn new() -> Self {
let logger = TestLogger::new();
let mut initial_sync_complete = false;
- let arc_logger = Arc::new(logger);
let network_graph = if let Ok(file) = File::open(&config::network_graph_cache_path()) {
println!("Initializing from cached network graph…");
let mut buffered_reader = BufReader::new(file);
- let network_graph_result = NetworkGraph::read(&mut buffered_reader, Arc::clone(&arc_logger));
+ let network_graph_result = NetworkGraph::read(&mut buffered_reader, logger);
if let Ok(network_graph) = network_graph_result {
initial_sync_complete = true;
network_graph.remove_stale_channels();
network_graph
} else {
println!("Initialization from cached network graph failed: {}", network_graph_result.err().unwrap());
- NetworkGraph::new(genesis_block(Network::Bitcoin).header.block_hash(), arc_logger)
+ NetworkGraph::new(genesis_block(Network::Bitcoin).header.block_hash(), logger)
}
} else {
- NetworkGraph::new(genesis_block(Network::Bitcoin).header.block_hash(), arc_logger)
+ NetworkGraph::new(genesis_block(Network::Bitcoin).header.block_hash(), logger)
};
let arc_network_graph = Arc::new(network_graph);
Self {
}
}
-async fn serialize_delta(network_graph: Arc<NetworkGraph<Arc<TestLogger>>>, last_sync_timestamp: u32, consider_intermediate_updates: bool) -> SerializedResponse {
+async fn serialize_delta(network_graph: Arc<NetworkGraph<TestLogger>>, last_sync_timestamp: u32, consider_intermediate_updates: bool) -> SerializedResponse {
let (client, connection) = lookup::connect_to_db().await;
tokio::spawn(async move {
/// whether they had been seen before.
/// Also include all announcements for which the first update was announced
/// after `last_syc_timestamp`
-pub(super) async fn fetch_channel_announcements(delta_set: &mut DeltaSet, network_graph: Arc<NetworkGraph<Arc<TestLogger>>>, client: &Client, last_sync_timestamp: u32) {
+pub(super) async fn fetch_channel_announcements(delta_set: &mut DeltaSet, network_graph: Arc<NetworkGraph<TestLogger>>, client: &Client, last_sync_timestamp: u32) {
let last_sync_timestamp_object = SystemTime::UNIX_EPOCH.add(Duration::from_secs(last_sync_timestamp as u64));
println!("Obtaining channel ids from network graph");
let channel_ids = {
pub(crate) struct GossipPersister {
gossip_persistence_receiver: mpsc::Receiver<GossipMessage>,
server_sync_completion_sender: mpsc::Sender<()>,
- network_graph: Arc<NetworkGraph<Arc<TestLogger>>>,
+ network_graph: Arc<NetworkGraph<TestLogger>>,
}
impl GossipPersister {
- pub fn new(server_sync_completion_sender: mpsc::Sender<()>, network_graph: Arc<NetworkGraph<Arc<TestLogger>>>) -> (Self, mpsc::Sender<GossipMessage>) {
+ pub fn new(server_sync_completion_sender: mpsc::Sender<()>, network_graph: Arc<NetworkGraph<TestLogger>>) -> (Self, mpsc::Sender<GossipMessage>) {
let (gossip_persistence_sender, gossip_persistence_receiver) =
mpsc::channel::<GossipMessage>(100);
(GossipPersister {
use crate::{config, TestLogger};
pub(crate) struct Snapshotter {
- network_graph: Arc<NetworkGraph<Arc<TestLogger>>>,
+ network_graph: Arc<NetworkGraph<TestLogger>>,
}
impl Snapshotter {
- pub fn new(network_graph: Arc<NetworkGraph<Arc<TestLogger>>>) -> Self {
+ pub fn new(network_graph: Arc<NetworkGraph<TestLogger>>) -> Self {
Self { network_graph }
}
use crate::downloader::GossipRouter;
use crate::types::{GossipMessage, GossipPeerManager};
-pub(crate) async fn download_gossip(persistence_sender: mpsc::Sender<GossipMessage>, network_graph: Arc<NetworkGraph<Arc<TestLogger>>>) {
+pub(crate) async fn download_gossip(persistence_sender: mpsc::Sender<GossipMessage>, network_graph: Arc<NetworkGraph<TestLogger>>) {
let mut key = [0; 32];
let mut random_data = [0; 32];
thread_rng().fill_bytes(&mut key);
message_handler,
our_node_secret,
&random_data,
- Arc::new(TestLogger::new()),
+ TestLogger::new(),
IgnoringMessageHandler {},
));
use std::sync::Arc;
+use std::ops::Deref;
use lightning::ln::msgs::{ChannelAnnouncement, ChannelUpdate};
use lightning::ln::peer_handler::{ErroringMessageHandler, IgnoringMessageHandler, PeerManager};
use crate::verifier::ChainVerifier;
pub(crate) type GossipChainAccess = Arc<ChainVerifier>;
-pub(crate) type GossipPeerManager = Arc<PeerManager<lightning_net_tokio::SocketDescriptor, ErroringMessageHandler, Arc<GossipRouter>, Arc<TestLogger>, IgnoringMessageHandler>>;
+pub(crate) type GossipPeerManager = Arc<PeerManager<lightning_net_tokio::SocketDescriptor, ErroringMessageHandler, Arc<GossipRouter>, TestLogger, IgnoringMessageHandler>>;
#[derive(Debug)]
pub(crate) enum GossipMessage {
InitialSyncComplete,
}
+#[derive(Clone, Copy)]
pub(crate) struct TestLogger {}
+impl Deref for TestLogger {
+ type Target = Self;
+ fn deref(&self) -> &Self { self }
+}
impl TestLogger {
pub(crate) fn new() -> TestLogger {