Skip to content

Commit 109a412

Browse files
Change ChanInfo.DirChanInfo fields to alice/bob
1 parent eb1e6fb commit 109a412

File tree

2 files changed

+50
-50
lines changed

2 files changed

+50
-50
lines changed

lightning/src/routing/network_graph.rs

Lines changed: 43 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -147,15 +147,15 @@ impl<C: Deref + Sync + Send, L: Deref + Sync + Send> RoutingMessageHandler for N
147147
if let Some((_, ref chan)) = iter.next() {
148148
if chan.announcement_message.is_some() {
149149
let chan_announcement = chan.announcement_message.clone().unwrap();
150-
let mut one_to_two_announcement: Option<msgs::ChannelUpdate> = None;
151-
let mut two_to_one_announcement: Option<msgs::ChannelUpdate> = None;
152-
if let Some(one_to_two) = chan.one_to_two.as_ref() {
153-
one_to_two_announcement = one_to_two.last_update_message.clone();
150+
let mut alice_to_bob_announcement: Option<msgs::ChannelUpdate> = None;
151+
let mut bob_to_alice_announcement: Option<msgs::ChannelUpdate> = None;
152+
if let Some(alice_to_bob) = chan.alice_to_bob.as_ref() {
153+
alice_to_bob_announcement = alice_to_bob.last_update_message.clone();
154154
}
155-
if let Some(two_to_one) = chan.two_to_one.as_ref() {
156-
two_to_one_announcement = two_to_one.last_update_message.clone();
155+
if let Some(bob_to_alice) = chan.bob_to_alice.as_ref() {
156+
bob_to_alice_announcement = bob_to_alice.last_update_message.clone();
157157
}
158-
result.push((chan_announcement, one_to_two_announcement, two_to_one_announcement));
158+
result.push((chan_announcement, alice_to_bob_announcement, bob_to_alice_announcement));
159159
} else {
160160
// TODO: We may end up sending un-announced channel_updates if we are sending
161161
// initial sync data while receiving announce/updates for this channel.
@@ -283,11 +283,11 @@ pub struct ChannelInfo {
283283
/// Source node of the first direction of a channel
284284
pub node_one: PublicKey,
285285
/// Details about the first direction of a channel
286-
pub one_to_two: Option<DirectionalChannelInfo>,
286+
pub alice_to_bob: Option<DirectionalChannelInfo>,
287287
/// Source node of the second direction of a channel
288288
pub node_two: PublicKey,
289289
/// Details about the second direction of a channel
290-
pub two_to_one: Option<DirectionalChannelInfo>,
290+
pub bob_to_alice: Option<DirectionalChannelInfo>,
291291
/// An initial announcement of the channel
292292
/// Mostly redundant with the data we store in fields explicitly.
293293
/// Everything else is useful only for sending out for initial routing sync.
@@ -297,18 +297,18 @@ pub struct ChannelInfo {
297297

298298
impl std::fmt::Display for ChannelInfo {
299299
fn fmt(&self, f: &mut std::fmt::Formatter) -> Result<(), std::fmt::Error> {
300-
write!(f, "features: {}, node_one: {}, one_to_two: {:?}, node_two: {}, two_to_one: {:?}",
301-
log_bytes!(self.features.encode()), log_pubkey!(self.node_one), self.one_to_two, log_pubkey!(self.node_two), self.two_to_one)?;
300+
write!(f, "features: {}, node_one: {}, alice_to_bob: {:?}, node_two: {}, bob_to_alice: {:?}",
301+
log_bytes!(self.features.encode()), log_pubkey!(self.node_one), self.alice_to_bob, log_pubkey!(self.node_two), self.bob_to_alice)?;
302302
Ok(())
303303
}
304304
}
305305

306306
impl_writeable!(ChannelInfo, 0, {
307307
features,
308308
node_one,
309-
one_to_two,
309+
alice_to_bob,
310310
node_two,
311-
two_to_one,
311+
bob_to_alice,
312312
announcement_message
313313
});
314314

@@ -550,8 +550,8 @@ impl NetworkGraph {
550550
for route_hop in path {
551551
let short_channel_id = route_hop.short_channel_id;
552552
if let Some(channel) = self.channels.get_mut(&short_channel_id) {
553-
channel.one_to_two.as_mut().unwrap().channel_score.payment_sent_score += 1;
554-
channel.two_to_one.as_mut().unwrap().channel_score.payment_sent_score += 1;
553+
channel.alice_to_bob.as_mut().unwrap().channel_score.payment_sent_score += 1;
554+
channel.bob_to_alice.as_mut().unwrap().channel_score.payment_sent_score += 1;
555555
} else {
556556
channel_down = true;
557557
continue;
@@ -578,9 +578,9 @@ impl NetworkGraph {
578578
let short_channel_id = route_hop.short_channel_id;
579579
let channel = self.channels.get_mut(&short_channel_id).unwrap();
580580
let directional_channel_info = if route_hop.pubkey == channel.node_one {
581-
channel.one_to_two.as_mut().unwrap()
581+
channel.alice_to_bob.as_mut().unwrap()
582582
} else {
583-
channel.two_to_one.as_mut().unwrap()
583+
channel.bob_to_alice.as_mut().unwrap()
584584
};
585585
let channel_score = &mut directional_channel_info.channel_score;
586586
if faultive_nodes.contains(&(route_hop.pubkey)) {
@@ -645,9 +645,9 @@ impl NetworkGraph {
645645
let chan_info = ChannelInfo {
646646
features: msg.contents.features.clone(),
647647
node_one: msg.contents.node_id_1.clone(),
648-
one_to_two: None,
648+
alice_to_bob: None,
649649
node_two: msg.contents.node_id_2.clone(),
650-
two_to_one: None,
650+
bob_to_alice: None,
651651
announcement_message: if should_relay { Some(msg.clone()) } else { None },
652652
};
653653

@@ -710,11 +710,11 @@ impl NetworkGraph {
710710
}
711711
} else {
712712
if let Some(chan) = self.channels.get_mut(&short_channel_id) {
713-
if let Some(one_to_two) = chan.one_to_two.as_mut() {
714-
one_to_two.enabled = false;
713+
if let Some(alice_to_bob) = chan.alice_to_bob.as_mut() {
714+
alice_to_bob.enabled = false;
715715
}
716-
if let Some(two_to_one) = chan.two_to_one.as_mut() {
717-
two_to_one.enabled = false;
716+
if let Some(bob_to_alice) = chan.bob_to_alice.as_mut() {
717+
bob_to_alice.enabled = false;
718718
}
719719
}
720720
}
@@ -780,13 +780,13 @@ impl NetworkGraph {
780780
if let Some(sig_verifier) = secp_ctx {
781781
secp_verify_sig!(sig_verifier, &msg_hash, &msg.signature, &channel.node_two);
782782
}
783-
maybe_update_channel_info!(channel.two_to_one, channel.node_two);
783+
maybe_update_channel_info!(channel.bob_to_alice, channel.node_two);
784784
} else {
785785
dest_node_id = channel.node_two.clone();
786786
if let Some(sig_verifier) = secp_ctx {
787787
secp_verify_sig!(sig_verifier, &msg_hash, &msg.signature, &channel.node_one);
788788
}
789-
maybe_update_channel_info!(channel.one_to_two, channel.node_one);
789+
maybe_update_channel_info!(channel.alice_to_bob, channel.node_one);
790790
}
791791
}
792792
}
@@ -811,9 +811,9 @@ impl NetworkGraph {
811811
let chan = self.channels.get(chan_id).unwrap();
812812
let chan_info_opt;
813813
if chan.node_one == dest_node_id {
814-
chan_info_opt = chan.two_to_one.as_ref();
814+
chan_info_opt = chan.bob_to_alice.as_ref();
815815
} else {
816-
chan_info_opt = chan.one_to_two.as_ref();
816+
chan_info_opt = chan.alice_to_bob.as_ref();
817817
}
818818
if let Some(chan_info) = chan_info_opt {
819819
if chan_info.enabled {
@@ -1260,8 +1260,8 @@ mod tests {
12601260
match network.get_channels().get(&short_channel_id) {
12611261
None => panic!(),
12621262
Some(channel_info) => {
1263-
assert_eq!(channel_info.one_to_two.as_ref().unwrap().cltv_expiry_delta, 144);
1264-
assert!(channel_info.two_to_one.is_none());
1263+
assert_eq!(channel_info.alice_to_bob.as_ref().unwrap().cltv_expiry_delta, 144);
1264+
assert!(channel_info.bob_to_alice.is_none());
12651265
}
12661266
}
12671267
}
@@ -1395,7 +1395,7 @@ mod tests {
13951395
match network.get_channels().get(&short_channel_id) {
13961396
None => panic!(),
13971397
Some(channel_info) => {
1398-
assert!(channel_info.one_to_two.is_some());
1398+
assert!(channel_info.alice_to_bob.is_some());
13991399
}
14001400
}
14011401
}
@@ -1413,7 +1413,7 @@ mod tests {
14131413
match network.get_channels().get(&short_channel_id) {
14141414
None => panic!(),
14151415
Some(channel_info) => {
1416-
assert!(!channel_info.one_to_two.as_ref().unwrap().enabled);
1416+
assert!(!channel_info.alice_to_bob.as_ref().unwrap().enabled);
14171417
}
14181418
}
14191419
}
@@ -1803,7 +1803,7 @@ mod tests {
18031803
let mut network = net_graph_msg_handler.network_graph.write().unwrap();
18041804
let chan_id = network.get_nodes().get(&node_id_1).unwrap().channels[0];
18051805
let channel_info = network.channels.get_mut(&chan_id).unwrap();
1806-
// Assign a DirectionalChannelInfo and ChannelScore object to one_to_two of
1806+
// Assign a DirectionalChannelInfo and ChannelScore object to alice_to_bob of
18071807
// channel_info
18081808
let chan_score_1 = ChannelScore {
18091809
payment_sent_score: 0,
@@ -1838,11 +1838,11 @@ mod tests {
18381838
channel_score: chan_score_2,
18391839
};
18401840

1841-
channel_info.one_to_two = Some(dir_chan_info_1);
1842-
channel_info.two_to_one = Some(dir_chan_info_2);
1843-
let dir_one_to_two = channel_info.one_to_two.as_mut().unwrap();
1844-
assert_eq!(dir_one_to_two.channel_score.payment_sent_score, 0);
1845-
assert_eq!(dir_one_to_two.channel_score.payment_failed_score, 0);
1841+
channel_info.alice_to_bob = Some(dir_chan_info_1);
1842+
channel_info.bob_to_alice = Some(dir_chan_info_2);
1843+
let dir_alice_to_bob = channel_info.alice_to_bob.as_mut().unwrap();
1844+
assert_eq!(dir_alice_to_bob.channel_score.payment_sent_score, 0);
1845+
assert_eq!(dir_alice_to_bob.channel_score.payment_failed_score, 0);
18461846
}
18471847

18481848
{
@@ -1864,9 +1864,9 @@ mod tests {
18641864
// Check that score_payment_sent_for_route incremented the appropriate ChannelScore
18651865
let chan_id = network.get_nodes().get(&node_id_1).unwrap().channels[0];
18661866
let channel_info = network.channels.get_mut(&chan_id).unwrap();
1867-
let dir_one_to_two = &channel_info.one_to_two.as_ref();
1868-
assert_eq!(dir_one_to_two.unwrap().channel_score.payment_sent_score, 1);
1869-
assert_eq!(dir_one_to_two.unwrap().channel_score.payment_failed_score, 0);
1867+
let dir_alice_to_bob = &channel_info.alice_to_bob.as_ref();
1868+
assert_eq!(dir_alice_to_bob.unwrap().channel_score.payment_sent_score, 1);
1869+
assert_eq!(dir_alice_to_bob.unwrap().channel_score.payment_failed_score, 0);
18701870
}
18711871

18721872
{
@@ -1890,9 +1890,9 @@ mod tests {
18901890
let chan_id = network.get_nodes().get(&node_id_1).unwrap().channels[0];
18911891
let channel_info = network.channels.get_mut(&chan_id).unwrap();
18921892
assert!(channel_info.node_two == node_id_2);
1893-
let dir_one_to_two = &channel_info.one_to_two.as_ref();
1894-
assert_eq!(dir_one_to_two.unwrap().channel_score.payment_sent_score, 1);
1895-
assert_eq!(dir_one_to_two.unwrap().channel_score.payment_failed_score, 1);
1893+
let dir_alice_to_bob = &channel_info.alice_to_bob.as_ref();
1894+
assert_eq!(dir_alice_to_bob.unwrap().channel_score.payment_sent_score, 1);
1895+
assert_eq!(dir_alice_to_bob.unwrap().channel_score.payment_failed_score, 1);
18961896
}
18971897
}
18981898
}

lightning/src/routing/router.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -301,19 +301,19 @@ pub fn get_route<C: Deref, L: Deref>(our_node_id: &PublicKey, net_graph_msg_hand
301301
let chan = network.get_channels().get(chan_id).unwrap();
302302
if !chan.features.requires_unknown_bits() {
303303
if chan.node_one == *$node_id {
304-
// ie $node is one, ie next hop in A* is two, via the two_to_one channel
304+
// ie $node is one, ie next hop in A* is two, via the bob_to_alice channel
305305
if first_hops.is_none() || chan.node_two != *our_node_id {
306-
if let Some(two_to_one) = chan.two_to_one.as_ref() {
307-
if two_to_one.enabled {
308-
add_entry!(chan_id, chan.node_two, chan.node_one, two_to_one, chan.features, $fee_to_target_msat);
306+
if let Some(bob_to_alice) = chan.bob_to_alice.as_ref() {
307+
if bob_to_alice.enabled {
308+
add_entry!(chan_id, chan.node_two, chan.node_one, bob_to_alice, chan.features, $fee_to_target_msat);
309309
}
310310
}
311311
}
312312
} else {
313313
if first_hops.is_none() || chan.node_one != *our_node_id {
314-
if let Some(one_to_two) = chan.one_to_two.as_ref() {
315-
if one_to_two.enabled {
316-
add_entry!(chan_id, chan.node_one, chan.node_two, one_to_two, chan.features, $fee_to_target_msat);
314+
if let Some(alice_to_bob) = chan.alice_to_bob.as_ref() {
315+
if alice_to_bob.enabled {
316+
add_entry!(chan_id, chan.node_one, chan.node_two, alice_to_bob, chan.features, $fee_to_target_msat);
317317
}
318318
}
319319

0 commit comments

Comments
 (0)