From 402b3a694e7253e9811e529d00ff4df87567f64b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vlado=20Paji=C4=87?= Date: Fri, 24 Jul 2026 10:04:24 +0200 Subject: [PATCH] improvements --- tutorial/tutorial_10_peerstore.cpp | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/tutorial/tutorial_10_peerstore.cpp b/tutorial/tutorial_10_peerstore.cpp index b647246..66c95d1 100644 --- a/tutorial/tutorial_10_peerstore.cpp +++ b/tutorial/tutorial_10_peerstore.cpp @@ -127,27 +127,22 @@ int main() fprintf(stderr, "peerstoreGetPeerInfo returned a non-object value\n"); return 1; } - auto& j = ownInfo.value; + printf(" Peer ID: %s\n", - j["peerId"].get().c_str()); + remoteStoreInfo.value["peerId"].get().c_str()); + printf(" Public key: %s\n", + remoteStoreInfo.value["publicKey"].get().c_str()); printf(" Addresses:\n"); - if (j.contains("addrs") && j["addrs"].is_array()) { - for (const auto& a : j["addrs"]) { - printf(" %s\n", a.get().c_str()); - } + for (const auto& a : remoteStoreInfo.value["addrs"]) { + printf(" %s\n", a.get().c_str()); } printf(" Protocols:\n"); - if (j.contains("protocols") && j["protocols"].is_array()) { - for (const auto& p : j["protocols"]) { - printf(" %s\n", p.get().c_str()); - } + for (const auto& p : remoteStoreInfo.value["protocols"]) { + printf(" %s\n", p.get().c_str()); } - printf(" Public key: %s\n", - j["publicKey"].get().c_str()); - /// ## Step 4: Manually add a peer to the store /// /// You can manually register peers in the store. This is useful for @@ -190,7 +185,6 @@ int main() fprintf(stderr, "peerstoreGetPeers returned a non-array value\n"); return 1; } - printf("Now have %zu known peer(s)\n", peersAfter.value.size()); /// ## Step 5: Update peer info ///