mirror of
https://github.com/oxen-io/lokinet.git
synced 2024-11-11 07:10:36 +00:00
dont use optional
This commit is contained in:
parent
23bcfa4abb
commit
4d4b33607f
@ -462,13 +462,11 @@ namespace llarp
|
|||||||
{
|
{
|
||||||
/// number of routers to publish to
|
/// number of routers to publish to
|
||||||
static constexpr size_t PublishRedundancy = 2;
|
static constexpr size_t PublishRedundancy = 2;
|
||||||
const auto maybe =
|
const auto paths =
|
||||||
GetManyPathsWithUniqueEndpoints(this, PublishRedundancy);
|
GetManyPathsWithUniqueEndpoints(this, PublishRedundancy);
|
||||||
if(not maybe.has_value())
|
|
||||||
return false;
|
|
||||||
// do publishing for each path selected
|
// do publishing for each path selected
|
||||||
size_t published = 0;
|
size_t published = 0;
|
||||||
for(const auto& path : maybe.value())
|
for(const auto& path : paths)
|
||||||
{
|
{
|
||||||
if(PublishIntroSetVia(i, r, path))
|
if(PublishIntroSetVia(i, r, path))
|
||||||
{
|
{
|
||||||
@ -970,17 +968,13 @@ namespace llarp
|
|||||||
|
|
||||||
auto& lookups = m_state->m_PendingServiceLookups;
|
auto& lookups = m_state->m_PendingServiceLookups;
|
||||||
|
|
||||||
const auto maybe =
|
const auto paths =
|
||||||
GetManyPathsWithUniqueEndpoints(this, NumParalellLookups);
|
GetManyPathsWithUniqueEndpoints(this, NumParalellLookups);
|
||||||
if(not maybe.has_value())
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
using namespace std::placeholders;
|
using namespace std::placeholders;
|
||||||
size_t lookedUp = 0;
|
size_t lookedUp = 0;
|
||||||
const dht::Key_t location = remote.ToKey();
|
const dht::Key_t location = remote.ToKey();
|
||||||
for(const auto& path : maybe.value())
|
for(const auto& path : paths)
|
||||||
{
|
{
|
||||||
HiddenServiceAddressLookup* job = new HiddenServiceAddressLookup(
|
HiddenServiceAddressLookup* job = new HiddenServiceAddressLookup(
|
||||||
this, util::memFn(&Endpoint::OnLookup, this), location,
|
this, util::memFn(&Endpoint::OnLookup, this), location,
|
||||||
|
@ -43,7 +43,7 @@ namespace llarp
|
|||||||
};
|
};
|
||||||
|
|
||||||
template < typename Endpoint_t >
|
template < typename Endpoint_t >
|
||||||
static absl::optional< path::Path::UniqueEndpointSet_t >
|
static path::Path::UniqueEndpointSet_t
|
||||||
GetManyPathsWithUniqueEndpoints(Endpoint_t* ep, size_t N, size_t tries = 10)
|
GetManyPathsWithUniqueEndpoints(Endpoint_t* ep, size_t N, size_t tries = 10)
|
||||||
{
|
{
|
||||||
path::Path::UniqueEndpointSet_t paths;
|
path::Path::UniqueEndpointSet_t paths;
|
||||||
@ -54,9 +54,7 @@ namespace llarp
|
|||||||
if(path)
|
if(path)
|
||||||
paths.emplace(path);
|
paths.emplace(path);
|
||||||
} while(tries > 0 and paths.size() < N);
|
} while(tries > 0 and paths.size() < N);
|
||||||
if(paths.size() == N)
|
return paths;
|
||||||
return paths;
|
|
||||||
return {};
|
|
||||||
}
|
}
|
||||||
} // namespace service
|
} // namespace service
|
||||||
|
|
||||||
|
@ -228,10 +228,8 @@ namespace llarp
|
|||||||
return;
|
return;
|
||||||
const auto addr = currentIntroSet.A.Addr();
|
const auto addr = currentIntroSet.A.Addr();
|
||||||
|
|
||||||
const auto maybe = GetManyPathsWithUniqueEndpoints(this, 2);
|
const auto paths = GetManyPathsWithUniqueEndpoints(this, 2);
|
||||||
if(not maybe.has_value())
|
for(const auto& path : paths)
|
||||||
return;
|
|
||||||
for(const auto& path : maybe.value())
|
|
||||||
{
|
{
|
||||||
HiddenServiceAddressLookup* job = new HiddenServiceAddressLookup(
|
HiddenServiceAddressLookup* job = new HiddenServiceAddressLookup(
|
||||||
m_Endpoint,
|
m_Endpoint,
|
||||||
|
Loading…
Reference in New Issue
Block a user