-
Notifications
You must be signed in to change notification settings - Fork 406
Handle initial_routing_sync requests from peers in their Init messages (issue 148) #202
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Which are the reasons to split the 2 APIs in different traits ? Seems to me a Network store which can get you channel/node announcements but you can't update with new msgs from peers isn't gonna be really useful, is it ? One of the reason could be easing the management of different networks (public/privates) ? |
This comes back the SOLID principle, as currently the traits are quite clearly only message handling. As to your question for our implementation using the router struct, we should ensure both pointers point to the same object which seems kinda stupid. The only advantage of splitting the message handling and network api traits is if for some reason you as a user might want to add some kind of middleware between one or both. But I cant think of a reason why you would want to do this. |
I believe this is much cleaner code. I combined the two traits, and it now requires both from the same object. I have kept the naming in place for now, but I dont think they will be completely correct if we follow this layout. |
So I have played around with the idea of caching messages, as we need them to be signed. I dont think we can sign them as we need secret keys for that. |
Dunno why email response got dropped... Hmm, I think you missed my point about the pagination - if, for each peer currently getting a channel dump, you keep only the short_channel_id of the highest channel that we have told it about, then you keep it's network buffer full with updates by querying the Router for the next N updates starting at I'd X (and you can ensure they don't miss anything by relaying normally updates below X). In the current model you query, get a full list of updates and shove them into the Peet's network buffer all at once. Even if you re-query for the full set of channels each time more room is available in the network buffer (which would be expensive in its own) and send starting from some index you remember, you still end up with race conditions where you will either re-relay information about channels to them or miss relaying information to them because of updates while you were sending them the full set. |
f0672a4
to
cc88399
Compare
f6ef81d
to
1c7e142
Compare
src/ln/msgs.rs
Outdated
@@ -591,6 +592,8 @@ pub trait RoutingMessageHandler : Send + Sync { | |||
fn handle_channel_update(&self, msg: &ChannelUpdate) -> Result<bool, HandleError>; | |||
/// Handle some updates to the route graph that we learned due to an outbound failed payment. | |||
fn handle_htlc_fail_channel_update(&self, update: &HTLCFailChannelUpdate); | |||
///This returns a vec of vec's, one for ChannelAnnouncements, one for ChannelUpdates and one for NodeAnnouncements. It also returns the id of the last channel passed through |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It doesn't return a vec of vecs? Also this doc doesn't describe what the function is for.
src/ln/peer_handler.rs
Outdated
//we wait to see if the buffer clears before we retrieve more message to send | ||
//we push up to 15 message out, 5 remaining means they have cleared 2/3rds | ||
while peer.pending_outbound_buffer.len()>5{ | ||
thread::sleep(time::Duration::from_millis(50)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We shouldn't sleep here, we should instead mark where we are in the peer and add more messages to the outbound queue when we get a write_event() from the user.
1c7e142
to
adb39ae
Compare
Okay, so I created another macro that firs checks the messages then passes it on towards the encode and send macro |
f212c5e
to
4577cae
Compare
Okay, I think I added this to the correct location |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yea, I think this is the right approach, nice. Doesn't look like it should work (looks panic-y to me), but I didn't test it yet. Ideally this would come with a test, but I dont think we currently have any tests for PeerHandler, so I won't suggest its blocking, but it would be really nice to have something that tests PeerHandler if its gonna grow any more complicated.
I agree on the test thing, but we need to create tests to test the message interaction first (simulate the network with announcement and update messages) Otherwise its going to be a very fake kinda useless test, as we need to test the routing with this. |
244ad7e
to
00f3c88
Compare
40e8774
to
0a2aed9
Compare
82926a3
to
44e5203
Compare
1716ddb
to
fda1096
Compare
Will take as #247 the patch from this PR to that is TheBlueMatt@b46c3cc. |
I have made an initial outline for #148.
Although the code currently sits in router, I am thinking of doing it the same way as router and channelmanger is linked to peer_handler.
There is two ways we can do this, one through a new independent trait, which means that peer_handler will have two ref to router.
Or we replace MessageHandler.route_handler with a trait that incorporates RoutingMessagerHandler and NetworkAPI.