Skip to content

Commit

Permalink
feat(logs)!: print only first address of a Contact (#1555)
Browse files Browse the repository at this point in the history
* feat(logs)!: print only first address of a Contact

* chore: remove itertools from particle-protocol
  • Loading branch information
folex committed Apr 6, 2023
1 parent aa0dd94 commit 32a46b2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
1 change: 0 additions & 1 deletion particle-protocol/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ serde_derive = "1.0.158"
humantime-serde = { workspace = true }
log = { workspace = true }
derivative = { workspace = true }
itertools = { workspace = true }
base64 = { workspace = true }
tokio = { workspace = true }

Expand Down
15 changes: 10 additions & 5 deletions particle-protocol/src/contact.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@
* limitations under the License.
*/

use fluence_libp2p::peerid_serializer;
use std::fmt::{Display, Formatter};

use itertools::Itertools;
use libp2p::{core::Multiaddr, PeerId};
use serde::{Deserialize, Serialize};
use std::fmt::{Display, Formatter};

use fluence_libp2p::peerid_serializer;

#[derive(Debug, Clone, Deserialize, Serialize, Eq, PartialEq)]
pub struct Contact {
Expand All @@ -39,8 +39,13 @@ impl Display for Contact {
if self.addresses.is_empty() {
write!(f, "{} @ [no addr]", self.peer_id)
} else {
let addrs = self.addresses.iter().join(" ");
write!(f, "{} @ [{}]", self.peer_id, addrs)
write!(
f,
"{} @ [{}, ({} more)]",
self.peer_id,
self.addresses[0],
self.addresses.len() - 1
)
}
}
}

0 comments on commit 32a46b2

Please sign in to comment.