17 auto res = libp2p::peer::PeerId::fromBase58(
18 "12D3KooWFN2mhgpkJsDBuNuE5427AcDrsib8EoqGMZmkxWwx3Md4");
25 std::vector<std::string> addresses;
26 for (
const auto &addr : peer_info.addresses) {
27 addresses.emplace_back(addr.getStringAddress());
29 return s << peer_info.id.toBase58() << addresses;
32 scale::ScaleDecoderStream &
operator>>(scale::ScaleDecoderStream &s,
34 std::string peer_id_base58;
35 std::vector<std::string> addresses;
36 s >> peer_id_base58 >> addresses;
37 auto peer_id_res = libp2p::peer::PeerId::fromBase58(peer_id_base58);
38 if (not peer_id_res) {
39 throw std::runtime_error(peer_id_res.error().message());
41 peer_info.id = std::move(peer_id_res.value());
42 std::vector<libp2p::multi::Multiaddress> multi_addrs;
43 multi_addrs.reserve(addresses.size());
45 addresses.begin(), addresses.end(), [&multi_addrs](
const auto &addr) {
47 auto res = libp2p::multi::Multiaddress::create(addr);
49 multi_addrs.emplace_back(std::move(res.value()));
52 peer_info.addresses = std::move(multi_addrs);
static libp2p::peer::PeerId dummyPeerId()
scale::ScaleEncoderStream & operator<<(scale::ScaleEncoderStream &s, const libp2p::peer::PeerInfo &peer_info)
libp2p::peer::PeerInfo PeerInfo
libp2p::peer::PeerId PeerId
scale::ScaleDecoderStream & operator>>(scale::ScaleDecoderStream &s, libp2p::peer::PeerInfo &peer_info)