Skip to content

Commit

Permalink
Remove some gossip message command in network actor
Browse files Browse the repository at this point in the history
  • Loading branch information
contrun committed Nov 19, 2024
1 parent e8292e3 commit a832ef6
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 48 deletions.
26 changes: 11 additions & 15 deletions src/fiber/channel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use crate::{
fiber::{
fee::calculate_tlc_forward_fee,
network::{get_chain_hash, SendOnionPacketCommand},
types::{ChannelUpdate, TlcErr, TlcErrPacket, TlcErrorCode},
types::{BroadcastMessage, ChannelUpdate, TlcErr, TlcErrPacket, TlcErrorCode},
},
invoice::{CkbInvoice, CkbInvoiceStatus, InvoiceStore},
};
Expand Down Expand Up @@ -1478,10 +1478,9 @@ where

self.network
.send_message(NetworkActorMessage::new_command(
NetworkActorCommand::ProccessChannelUpdate(
self.get_remote_peer_id(),
NetworkActorCommand::BroadcastMessage(BroadcastMessage::ChannelUpdate(
update,
),
)),
))
.expect(ASSUME_NETWORK_ACTOR_ALIVE);

Expand Down Expand Up @@ -2621,10 +2620,9 @@ impl ChannelActorState {

network
.send_message(NetworkActorMessage::new_command(
NetworkActorCommand::ProccessChannelUpdate(
self.get_remote_peer_id(),
NetworkActorCommand::BroadcastMessage(BroadcastMessage::ChannelUpdate(
channel_update,
),
)),
))
.expect(ASSUME_NETWORK_ACTOR_ALIVE);
}
Expand Down Expand Up @@ -4626,11 +4624,10 @@ impl ChannelActorState {
);
network
.send_message(NetworkActorMessage::new_command(
NetworkActorCommand::ProcessChannelAnnouncement(
self.get_remote_peer_id(),
self.get_funding_transaction_block_number(),
self.get_funding_transaction_index(),
channel_announcement,
NetworkActorCommand::BroadcastMessage(
crate::fiber::types::BroadcastMessage::ChannelAnnouncement(
channel_announcement,
),
),
))
.expect(ASSUME_NETWORK_ACTOR_ALIVE);
Expand All @@ -4641,10 +4638,9 @@ impl ChannelActorState {

network
.send_message(NetworkActorMessage::new_command(
NetworkActorCommand::ProccessChannelUpdate(
self.get_remote_peer_id(),
NetworkActorCommand::BroadcastMessage(BroadcastMessage::ChannelUpdate(
channel_update,
),
)),
))
.expect(ASSUME_NETWORK_ACTOR_ALIVE);
}
Expand Down
33 changes: 0 additions & 33 deletions src/fiber/network.rs
Original file line number Diff line number Diff line change
Expand Up @@ -211,17 +211,6 @@ pub enum NetworkActorCommand {
),
UpdateChannelFunding(Hash256, Transaction, FundingRequest),
SignTx(PeerId, Hash256, Transaction, Option<Vec<Vec<u8>>>),
// A ChannelAnnouncement is ready to broadcast, we need to
// update our network graph and broadcast it to the network.
// The channel counterparty should definitely be part of the
// nodes that are going to receive this message.
ProcessChannelAnnouncement(PeerId, BlockNumber, u32, ChannelAnnouncement),
// A ChannelUpdate is ready to broadcast, we need to update
// our network graph and broadcast it to the network.
// The channel counterparty should definitely be part of the
// nodes that are going to receive this message.
ProccessChannelUpdate(PeerId, ChannelUpdate),
// Broadcast node/channel information to the network.
BroadcastMessage(BroadcastMessage),
// Broadcast local information to the network.
BroadcastLocalInfo(LocalInfoKind),
Expand Down Expand Up @@ -1284,29 +1273,7 @@ where
);
}
},
NetworkActorCommand::ProcessChannelAnnouncement(
peer_id,
block_number,
tx_index,
channel_announcement,
) => {
debug!(
"Processing our channel announcement message (confirmed at #{} block #{} tx) to peer {:?}: {:?}",
&block_number,
&tx_index,
&peer_id,
&channel_announcement
);
// TODO: Save the channel announcement to the database.
}

NetworkActorCommand::ProccessChannelUpdate(peer_id, channel_update) => {
debug!(
"Processing our channel update message to peer {:?}: {:?}",
&peer_id, &channel_update
);
// TODO: Save the channel update to the database.
}
NetworkActorCommand::NodeInfo(_, rpc) => {
let response = NodeInfoResponse {
node_name: state.node_name.clone(),
Expand Down

0 comments on commit a832ef6

Please sign in to comment.