Replace from_string_checked pair return type with optional<Endpoint>

This commit is contained in:
seelabs
2019-08-14 13:39:49 -07:00
parent 0a256247a0
commit 1eb3753f26
8 changed files with 48 additions and 49 deletions

View File

@@ -1304,11 +1304,11 @@ PeerImp::onMessage(std::shared_ptr <protocol::TMPeerShardInfo> const& m)
{
if (m->endpoint() != "0")
{
auto [result, validResult] =
auto result =
beast::IP::Endpoint::from_string_checked(m->endpoint());
if (!validResult)
if (!result)
return badData("Invalid incoming endpoint: " + m->endpoint());
endpoint = std::move(result);
endpoint = std::move(*result);
}
}
else if (crawl()) // Check if peer will share IP publicly
@@ -1384,8 +1384,8 @@ PeerImp::onMessage (std::shared_ptr <protocol::TMEndpoints> const& m)
for (auto const& tm : m->endpoints_v2 ())
{
// these endpoint strings support ipv4 and ipv6
auto [result, validResult] = beast::IP::Endpoint::from_string_checked(tm.endpoint());
if (! validResult)
auto result = beast::IP::Endpoint::from_string_checked(tm.endpoint());
if (! result)
{
JLOG(p_journal_.error()) <<
"failed to parse incoming endpoint: {" <<
@@ -1402,8 +1402,8 @@ PeerImp::onMessage (std::shared_ptr <protocol::TMEndpoints> const& m)
endpoints.emplace_back(
tm.hops() > 0 ?
result :
remote_address_.at_port(result.port()),
*result :
remote_address_.at_port(result->port()),
tm.hops());
JLOG(p_journal_.trace()) <<
"got v2 EP: " << endpoints.back().address <<