Ipfs private swarms interop example (#1420)

* Add gossipsub and ping

* Implement swarm key parsing from environment

* WIP remove stuff

* WIP remove more stuff

* Use gossipsub instead of floodsub

* Make ipfs example work with or without swarm key

* Add support for /ipfs/Qm1234 multiaddrs

* Add documentation for ipfs example

* Rename example to ipfs-private

* Fix comments

* Move EitherTransport into either.rs

And prettify imports of ipfs-private example

* Sanitize multiaddr before parsing

...and remove the "ipfs" protocol from multiaddr

* Remove TSubstream type parameter

...so that it works with current master

* PR feedback

use source instead of cause
This commit is contained in:
Rüdiger Klaehn
2020-02-10 18:35:51 +01:00
committed by GitHub
parent fc4dec581e
commit d55871623c
3 changed files with 379 additions and 1 deletions

View File

@ -161,6 +161,21 @@ pub enum KeyParseError {
InvalidKeyChar(ParseIntError),
}
impl fmt::Display for KeyParseError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{:?}", self)
}
}
impl error::Error for KeyParseError {
fn source(&self) -> Option<&(dyn error::Error + 'static)> {
match *self {
KeyParseError::InvalidKeyChar(ref err) => Some(err),
_ => None,
}
}
}
/// Private network configuration
#[derive(Debug, Copy, Clone)]
pub struct PnetConfig {