-
Notifications
You must be signed in to change notification settings - Fork 167
Conversation
|
||
/// The connections which have been requested, but the swarm/network is yet to ask for | ||
/// addresses; currently filled in the order of adding, with the default size of one. | ||
pending_addresses: HashMap<PeerId, Vec<Multiaddr>>, |
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.
I was wondering if a HashSet
wouldn't be better than having to do linear lookups, but I guess a Vec
should be faster for only a few entries, and I wouldn't expect more 👍
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.
Also the use in NetworkBehaviour::addresses_of_peer
which is just a pending_addresses.remove(peer_id).unwrap_or_default()
.
This is never expected to accumulate a lot of addresses. Perhaps there's a chance somehow to accumulate dead entries here, like getting libp2p_kad
dialing to the same peer at the sibling poll. Even in that case, the hashmap entry would get removed. Perhaps not in all cases. Overall it'd be easier to get access to the networking core of the Swarm for all of these, but at the same time I kind of agree hiding it is a good idea. Perhaps having access to HashSet<PeerId>
via PollParameters would work. Need to still keep thinking this :)
This comment was marked as outdated.
This comment was marked as outdated.
Sorry, something went wrong.
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.
Again, it seems that this is not so simple. I guess I'll have to follow up with another PR to see if this could just be "connect to the peer with this given multiaddr, or any other way". That should at least simplify a lot of the wrestling, and allow to use the non-provided methods of NetworkBehaviour.
Noted an additional "deadlock" with a peer racing to connect to us before our dialing attempt has completed. This should be solvable by redefining the connect
as "end up being in connection to a peer."
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.
This is quite outdated. Might be best to look again with fresh eyes :)
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.
LGTM
This comment has been minimized.
This comment has been minimized.
allows converting MultiaddrWithoutPeerId into MultiaddrWithPeerId
otherwise it'll poison the mutex and we'll get double panic during unwind.
95e8c30
to
00a806c
Compare
Decided not to do this after all; it would remove a lot of the sense/usecase of this cli functionality. As the PR included some back and forth, decided to squash most of it and dragged unrelated changes above the big commit. Couldn't really find a way to do it piecewise, as a number of test cases failed. I'll probably do a round of Ipfs:: method documentation scanning and then we are hopefully done with this. The PR now includes adaptation to libp2p/rust-libp2p#1619 which was skipped in the #446, which also changed how the NetworkBehaviour::inject_disconnect and single connection closed methods are now called (they were not previously) so there needed to be a hack. Might be that we'll need to do a quickfix to remove the debug_asserts but they should be correct now. |
while libp2p might soon gain the ability to dial peer addresses directly, this will be a stopgap until that. updated a bunch of comments and adapted to the since fixed missing events on banning the peer, which is still used to disconnect peer at will.
e30a7ae
to
01e058e
Compare
455: test: split off common_tests from common r=koivunej a=koivunej Tiny refactoring to stop testing `common::tests` as part of every top level `test/*.rs`, noticed during #454. Co-authored-by: Joonas Koivunen <[email protected]>
The amount of added untested code here isn't great. I have some ideas for more test cases but those done similarly as we've done them so far in Lines 268 to 287 in 23fc80b
bors r+ |
Build succeeded: |
The correct way to connect to a peer is in my understanding to DialPeer and then proceed to give the address of that said peer from
NetworkBehaviour::addresses_of_peer
. While doing this, the previous workaround for missing events from banning a peer (the way we force a disconnect) was also necessary to fix.