Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Improve checking for peer id mismatch #5369

Closed
bkchr opened this issue Mar 23, 2020 · 3 comments
Closed

Improve checking for peer id mismatch #5369

bkchr opened this issue Mar 23, 2020 · 3 comments
Labels
I7-refactor Code needs refactoring. Z2-medium Can be fixed by a coder with good Rust knowledge but little knowledge of the codebase.

Comments

@bkchr
Copy link
Member

bkchr commented Mar 23, 2020

#5365 introduced an error when we can not connect to a bootnode, because the requested peer id is different than the one returned by the remote node.

However, the implementation is based on string matching. This should be improved. A solution could be to provide a trait that is added to the boxed error in libp2p. The trait could look like this:

trait IsPeerIdMismatch {
    /// Returns `Some(_)` if `self` is a peer id mismatch error. The returned peer id is the one obtained from the remote node.
    fn is_peer_id_mismatch(&self) -> Option<PeerId>;
}

The trait would than be used to check the error, instead of using string matching.

cc @tomaka

@bkchr bkchr added I7-refactor Code needs refactoring. Z2-medium Can be fixed by a coder with good Rust knowledge but little knowledge of the codebase. labels Mar 23, 2020
@tomaka
Copy link
Contributor

tomaka commented Mar 23, 2020

Better is instead to not produce a Box<Error> but an enum.
The actual type that we Box is this. Returning it should be as simple as removing the Box::new here.

@bkchr
Copy link
Member Author

bkchr commented Mar 23, 2020

Yeah this is even better :) I just thought that boxing the error maybe had some reason.

@tomaka tomaka mentioned this issue Apr 6, 2020
@tomaka
Copy link
Contributor

tomaka commented Apr 9, 2020

Done in #5278

@tomaka tomaka closed this as completed Apr 9, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
I7-refactor Code needs refactoring. Z2-medium Can be fixed by a coder with good Rust knowledge but little knowledge of the codebase.
Projects
None yet
Development

No branches or pull requests

2 participants