Skip to content

Commit 0ea9d76

Browse files
committed
chore: trim leftover test helpers and formatting drift
1 parent 5002a51 commit 0ea9d76

3 files changed

Lines changed: 26 additions & 99 deletions

File tree

crates/fiber-lib/src/fiber/channel.rs

Lines changed: 13 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -2200,10 +2200,7 @@ where
22002200
));
22012201
}
22022202
ChannelState::NegotiatingFunding(_) => {
2203-
debug!(
2204-
"Beginning processing tx collaboration command, and transitioning from {:?} to CollaboratingFundingTx state",
2205-
state.state
2206-
);
2203+
debug!("Beginning processing tx collaboration command, and transitioning from {:?} to CollaboratingFundingTx state", state.state);
22072204
state.state =
22082205
ChannelState::CollaboratingFundingTx(CollaboratingFundingTxFlags::empty());
22092206
CollaboratingFundingTxFlags::empty()
@@ -2294,10 +2291,7 @@ where
22942291
state.funding_tx = Some(tx);
22952292
state.update_state(ChannelState::AwaitingTxSignatures(flags));
22962293
} else {
2297-
error!(
2298-
"Invalid state. Expect channel state to be AwaitingTxSignatures, but bot {:?}",
2299-
state.state
2300-
);
2294+
error!("Invalid state. Expect channel state to be AwaitingTxSignatures, but bot {:?}", state.state);
23012295
}
23022296
Ok(())
23032297
}
@@ -3933,6 +3927,7 @@ impl ChannelActorState {
39333927
fn on_peer_reconnected(&mut self) {
39343928
if self.reestablishing {
39353929
self.connectivity_state = ChannelConnectivityState::Syncing;
3930+
self.send_reestablish_message();
39363931
}
39373932
}
39383933

@@ -4857,10 +4852,8 @@ impl ChannelActorState {
48574852
self.to_local_amount = to_local_amount;
48584853
self.to_remote_amount = to_remote_amount;
48594854

4860-
debug!(
4861-
"Updated local balance to {} and remote balance to {} by removing tlc {:?} with reason {:?}",
4862-
to_local_amount, to_remote_amount, tlc_id, reason
4863-
);
4855+
debug!("Updated local balance to {} and remote balance to {} by removing tlc {:?} with reason {:?}",
4856+
to_local_amount, to_remote_amount, tlc_id, reason);
48644857
self.apply_remove_tlc(tlc_id);
48654858
}
48664859
debug!(
@@ -5626,9 +5619,7 @@ impl ChannelActorState {
56265619
debug!("We have sent our shutdown signature, waiting for counterparty's signature");
56275620
}
56285621
} else {
5629-
debug!(
5630-
"Not ready to shutdown the channel, waiting for both parties to send the Shutdown message"
5631-
);
5622+
debug!("Not ready to shutdown the channel, waiting for both parties to send the Shutdown message");
56325623
}
56335624

56345625
Ok(())
@@ -5681,8 +5672,7 @@ impl ChannelActorState {
56815672
_ => {
56825673
return Err(ProcessingChannelError::InvalidParameter(format!(
56835674
"Must/Mustn't send announcement nonce if channel is public/private, nonce {:?}, channel is public: {}",
5684-
&accept_channel.channel_announcement_nonce,
5685-
self.is_public()
5675+
&accept_channel.channel_announcement_nonce, self.is_public()
56865676
)));
56875677
}
56885678
}
@@ -5719,10 +5709,7 @@ impl ChannelActorState {
57195709
));
57205710
}
57215711
ChannelState::NegotiatingFunding(_) => {
5722-
debug!(
5723-
"Started negotiating funding tx collaboration, and transitioning from {:?} to CollaboratingFundingTx state",
5724-
self.state
5725-
);
5712+
debug!("Started negotiating funding tx collaboration, and transitioning from {:?} to CollaboratingFundingTx state", self.state);
57265713
self.state =
57275714
ChannelState::CollaboratingFundingTx(CollaboratingFundingTxFlags::empty());
57285715
CollaboratingFundingTxFlags::empty()
@@ -5925,9 +5912,7 @@ impl ChannelActorState {
59255912
flags: SigningCommitmentFlags,
59265913
) -> ProcessingChannelResult {
59275914
if flags.contains(SigningCommitmentFlags::COMMITMENT_SIGNED_SENT) {
5928-
debug!(
5929-
"Commitment signed message sent by both sides, transitioning to AwaitingTxSignatures state"
5930-
);
5915+
debug!("Commitment signed message sent by both sides, transitioning to AwaitingTxSignatures state");
59315916
self.update_state(ChannelState::AwaitingTxSignatures(
59325917
AwaitingTxSignaturesFlags::empty(),
59335918
));
@@ -6719,10 +6704,8 @@ impl ChannelActorState {
67196704
"udt_amount: {}, to_remote_amount: {}, to_local_amount: {}",
67206705
udt_amount, self.to_remote_amount, self.to_local_amount
67216706
);
6722-
debug!(
6723-
"current_capacity: {}, remote_reserved_ckb_amount: {}, local_reserved_ckb_amount: {}",
6724-
current_capacity, self.remote_reserved_ckb_amount, self.local_reserved_ckb_amount
6725-
);
6707+
debug!("current_capacity: {}, remote_reserved_ckb_amount: {}, local_reserved_ckb_amount: {}",
6708+
current_capacity, self.remote_reserved_ckb_amount, self.local_reserved_ckb_amount);
67266709
let is_udt_amount_ok = udt_amount == self.get_liquid_capacity();
67276710
return Ok(is_udt_amount_ok);
67286711
} else {
@@ -7014,10 +6997,8 @@ impl ChannelActorState {
70146997
} else {
70156998
debug!(
70166999
"Final balance partition before shutting down: local {} (fee {}), remote {} (fee {})",
7017-
self.to_local_amount,
7018-
local_shutdown_fee,
7019-
self.to_remote_amount,
7020-
remote_shutdown_fee
7000+
self.to_local_amount, local_shutdown_fee,
7001+
self.to_remote_amount, remote_shutdown_fee
70217002
);
70227003
let local_value =
70237004
self.to_local_amount as u64 + self.local_reserved_ckb_amount - local_shutdown_fee;

crates/fiber-lib/src/fiber/graph.rs

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1077,34 +1077,6 @@ where
10771077
self.source
10781078
}
10791079

1080-
#[cfg(any(test, feature = "bench"))]
1081-
pub fn debug_history_result(
1082-
&self,
1083-
channel_outpoint: &OutPoint,
1084-
from: Pubkey,
1085-
to: Pubkey,
1086-
) -> Option<TimedResult> {
1087-
let (direction, _) = super::history::output_direction(from, to);
1088-
self.history
1089-
.get_result(channel_outpoint, direction)
1090-
.copied()
1091-
}
1092-
1093-
#[cfg(any(test, feature = "bench"))]
1094-
pub fn debug_history_probability(
1095-
&self,
1096-
channel_outpoint: &OutPoint,
1097-
from: Pubkey,
1098-
to: Pubkey,
1099-
amount: u128,
1100-
) -> Option<f64> {
1101-
let channel = self.get_channel(channel_outpoint)?;
1102-
Some(
1103-
self.history
1104-
.eval_probability(from, to, channel_outpoint, amount, channel.capacity()),
1105-
)
1106-
}
1107-
11081080
pub(crate) fn mark_channel_failed(&mut self, channel_outpoint: &OutPoint) {
11091081
if let Some(channel) = self.channels.get_mut(channel_outpoint) {
11101082
if let Some(info) = channel.update_of_node2.as_mut() {

crates/fiber-lib/src/fiber/network.rs

Lines changed: 13 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,7 @@ use super::channel::{
5858
use super::gossip::{GossipActorMessage, GossipMessageStore, GossipMessageUpdates};
5959
use super::graph::{NetworkGraph, NetworkGraphStateStore, OwnedChannelUpdateEvent};
6060
use super::types::{
61-
BroadcastMessageWithTimestamp, FiberMessage, ForwardTlcResult, GossipMessage, Init,
62-
OpenChannel, ReestablishChannel,
61+
BroadcastMessageWithTimestamp, FiberMessage, ForwardTlcResult, GossipMessage, Init, OpenChannel,
6362
};
6463
use super::{
6564
FiberConfig, InFlightCkbTxActor, InFlightCkbTxActorArguments, InFlightCkbTxKind,
@@ -1273,18 +1272,17 @@ where
12731272

12741273
if num_inbound_peers > state.max_inbound_peers {
12751274
debug!(
1276-
"Already connected to {} inbound peers, only wants {} peers, disconnecting some",
1277-
num_inbound_peers, state.max_inbound_peers
1278-
);
1275+
"Already connected to {} inbound peers, only wants {} peers, disconnecting some",
1276+
num_inbound_peers, state.max_inbound_peers
1277+
);
12791278
inbound_peer_sessions.retain(|k| !state.session_channels_map.contains_key(k));
12801279
let sessions_to_disconnect = if inbound_peer_sessions.len()
12811280
< num_inbound_peers - state.max_inbound_peers
12821281
{
12831282
warn!(
1284-
"Wants to disconnect more {} inbound peers, but all peers except {:?} have channels, will not disconnect any peer with channels",
1285-
num_inbound_peers - state.max_inbound_peers,
1286-
&inbound_peer_sessions
1287-
);
1283+
"Wants to disconnect more {} inbound peers, but all peers except {:?} have channels, will not disconnect any peer with channels",
1284+
num_inbound_peers - state.max_inbound_peers, &inbound_peer_sessions
1285+
);
12881286
&inbound_peer_sessions[..]
12891287
} else {
12901288
&inbound_peer_sessions[..num_inbound_peers - state.max_inbound_peers]
@@ -1302,9 +1300,9 @@ where
13021300

13031301
if num_outbound_peers >= state.min_outbound_peers {
13041302
debug!(
1305-
"Already connected to {} outbound peers, wants a minimal of {} peers, skipping connecting to more peers",
1306-
num_outbound_peers, state.min_outbound_peers
1307-
);
1303+
"Already connected to {} outbound peers, wants a minimal of {} peers, skipping connecting to more peers",
1304+
num_outbound_peers, state.min_outbound_peers
1305+
);
13081306
return Ok(());
13091307
}
13101308

@@ -1342,9 +1340,9 @@ where
13421340
debug!("Peer to connect: {:?}, {:?}", pubkey, addresses);
13431341
if let Some(peer) = state.peer_session_map.get(&pubkey) {
13441342
debug!(
1345-
"Randomly selected peer {:?} already connected with session id {:?}, skipping connection",
1346-
pubkey, peer.session_id
1347-
);
1343+
"Randomly selected peer {:?} already connected with session id {:?}, skipping connection",
1344+
pubkey, peer.session_id
1345+
);
13481346
continue;
13491347
}
13501348

@@ -3998,8 +3996,6 @@ where
39983996
);
39993997
self.attach_channel_to_session(remote_pubkey, channel_id);
40003998
let _ = actor.send_message(ChannelActorMessage::Event(ChannelEvent::PeerReconnected));
4001-
self.send_reestablish_message(remote_pubkey, channel_id)
4002-
.await?;
40033999
return Ok(actor);
40044000
}
40054001

@@ -4041,28 +4037,6 @@ where
40414037

40424038
Ok(channel)
40434039
}
4044-
4045-
async fn send_reestablish_message(
4046-
&self,
4047-
remote_pubkey: Pubkey,
4048-
channel_id: Hash256,
4049-
) -> Result<(), Error> {
4050-
let channel_actor_state = self
4051-
.store
4052-
.get_channel_actor_state(&channel_id)
4053-
.ok_or(Error::ChannelNotFound(channel_id))?;
4054-
let reestablish_channel = ReestablishChannel {
4055-
channel_id,
4056-
local_commitment_number: channel_actor_state.get_local_commitment_number(),
4057-
remote_commitment_number: channel_actor_state.get_remote_commitment_number(),
4058-
};
4059-
self.send_fiber_message_to_pubkey(
4060-
&remote_pubkey,
4061-
FiberMessage::reestablish_channel(reestablish_channel),
4062-
)
4063-
.await
4064-
}
4065-
40664040
async fn on_peer_connected(&mut self, remote_pubkey: Pubkey, session: &SessionContext) {
40674041
debug!("Peer {:?} connected", remote_pubkey);
40684042
self.peer_session_map.insert(

0 commit comments

Comments
 (0)