|
@ -7,12 +7,12 @@ |
|
|
|
|
|
|
|
|
#include <tuple> |
|
|
#include <tuple> |
|
|
|
|
|
|
|
|
|
|
|
#include <generated/protocol/identify/protobuf/identify.pb.h> |
|
|
#include <boost/assert.hpp> |
|
|
#include <boost/assert.hpp> |
|
|
#include <libp2p/basic/protobuf_message_read_writer.hpp> |
|
|
#include <libp2p/basic/protobuf_message_read_writer.hpp> |
|
|
#include <libp2p/network/network.hpp> |
|
|
#include <libp2p/network/network.hpp> |
|
|
#include <libp2p/peer/address_repository.hpp> |
|
|
#include <libp2p/peer/address_repository.hpp> |
|
|
#include <libp2p/protocol/identify/utils.hpp> |
|
|
#include <libp2p/protocol/identify/utils.hpp> |
|
|
#include <generated/protocol/identify/protobuf/identify.pb.h> |
|
|
|
|
|
|
|
|
|
|
|
namespace { |
|
|
namespace { |
|
|
inline std::string fromMultiaddrToString(const libp2p::multi::Multiaddress &ma) { |
|
|
inline std::string fromMultiaddrToString(const libp2p::multi::Multiaddress &ma) { |
|
@ -354,16 +354,15 @@ namespace libp2p::protocol { |
|
|
log_->debug("can not get addresses for peer {}", peer_id.toBase58()); |
|
|
log_->debug("can not get addresses for peer {}", peer_id.toBase58()); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
switch (conn_manager_.connectedness({peer_id, addresses.value()})) { |
|
|
bool permanent_ttl = |
|
|
case network::ConnectionManager::Connectedness::CONNECTED: |
|
|
(addresses |
|
|
add_res = addr_repo.upsertAddresses(peer_id, listen_addresses, |
|
|
&& (conn_manager_.connectedness({peer_id, addresses.value()}) |
|
|
peer::ttl::kPermanent); |
|
|
== network::ConnectionManager::Connectedness::CONNECTED)); |
|
|
break; |
|
|
|
|
|
default: |
|
|
add_res = addr_repo.upsertAddresses( |
|
|
add_res = addr_repo.upsertAddresses(peer_id, listen_addresses, |
|
|
peer_id, listen_addresses, |
|
|
peer::ttl::kRecentlyConnected); |
|
|
permanent_ttl ? peer::ttl::kPermanent : peer::ttl::kRecentlyConnected); |
|
|
break; |
|
|
|
|
|
} |
|
|
|
|
|
if (!add_res) { |
|
|
if (!add_res) { |
|
|
log_->error("cannot add addresses to peer {}: {}", peer_id.toBase58(), |
|
|
log_->error("cannot add addresses to peer {}: {}", peer_id.toBase58(), |
|
|
add_res.error().message()); |
|
|
add_res.error().message()); |
|
|