Skip to content

Commit

Permalink
Make clippy happy
Browse files Browse the repository at this point in the history
  • Loading branch information
Tibo-lg committed Jul 10, 2024
1 parent f08147a commit f946eb9
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 31 deletions.
1 change: 0 additions & 1 deletion sample/examples/configurations/alice.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,5 @@ bitcoinInfo:
storageDirPath: './dlc_sample_alice'
networkConfiguration:
peerListeningPort: 9000
network: regtest
oracleConfig:
host: 'http://localhost:8080/'
1 change: 0 additions & 1 deletion sample/examples/configurations/bob.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,5 @@ bitcoinInfo:
storageDirPath: './dlc_sample_bob'
networkConfiguration:
peerListeningPort: 9001
network: regtest
oracleConfig:
host: 'http://localhost:8080/'
30 changes: 1 addition & 29 deletions sample/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ use crate::hex_utils;
use crate::DlcManager;
use crate::DlcMessageHandler;
use crate::PeerManager;
use bitcoin::network::constants::Network;
use bitcoin::secp256k1::PublicKey;
use dlc_manager::channel::signed_channel::SignedChannelState;
use dlc_manager::channel::signed_channel::SignedChannelStateType;
Expand All @@ -12,15 +11,13 @@ use dlc_manager::contract::Contract;
use dlc_manager::Storage;
use dlc_messages::Message as DlcMessage;
use hex_utils::{hex_str, to_slice};
use lightning::ln::msgs::SocketAddress;
use serde::Deserialize;
use serde_json::Value;
use std::convert::TryInto;
use std::fs;
use std::io;
use std::io::{BufRead, Write};
use std::net::{IpAddr, SocketAddr, ToSocketAddrs};
use std::str::FromStr;
use std::net::{SocketAddr, ToSocketAddrs};
use std::str::SplitWhitespace;
use std::sync::{Arc, Mutex};
use std::time::Duration;
Expand All @@ -44,7 +41,6 @@ pub struct OracleConfig {
#[derive(Debug)]
pub struct NetworkConfig {
pub peer_listening_port: u16,
pub announced_listen_addr: Option<SocketAddress>,
}

#[derive(Debug, Deserialize)]
Expand All @@ -54,9 +50,6 @@ pub struct Configuration {
pub storage_dir_path: String,
#[serde(deserialize_with = "deserialize_network_configuration")]
pub network_configuration: NetworkConfig,
#[serde(default)]
pub announced_node_name: [u8; 32],
pub network: Network,
pub oracle_config: OracleConfig,
}

Expand All @@ -72,29 +65,8 @@ where
.try_into()
.expect("Could not fit port in u16");

let announced_listen_addr = if let Some(announced_listen_addr) = val.get("announcedListenAddr")
{
let buf = announced_listen_addr
.as_str()
.expect("Error parsing announcedListenAddr");
match IpAddr::from_str(buf) {
Ok(IpAddr::V4(a)) => Some(SocketAddress::TcpIpV4 {
addr: a.octets(),
port: peer_listening_port,
}),
Ok(IpAddr::V6(a)) => Some(SocketAddress::TcpIpV6 {
addr: a.octets(),
port: peer_listening_port,
}),
Err(_) => panic!("Failed to parse announced-listen-addr into an IP address"),
}
} else {
None
};

Ok(NetworkConfig {
peer_listening_port,
announced_listen_addr,
})
}

Expand Down

0 comments on commit f946eb9

Please sign in to comment.