Asio error to stat detail

This commit is contained in:
Piotr Wójcik 2024-11-11 20:26:53 +01:00
commit c494819135
3 changed files with 31 additions and 0 deletions

View file

@ -152,6 +152,7 @@ enum class detail
sync,
requeued,
evicted,
other,
// processing queue
queue,
@ -582,6 +583,12 @@ enum class detail
rollback_skipped,
loop_scan,
// error codes
no_buffer_space,
timed_out,
host_unreachable,
not_supported,
_last // Must be the last enum
};

View file

@ -165,3 +165,22 @@ bool nano::transport::reserved_address (nano::endpoint const & endpoint_a, bool
}
return result;
}
nano::stat::detail nano::to_stat_detail (boost::system::error_code const & ec)
{
switch (ec.value ())
{
case boost::system::errc::success:
return nano::stat::detail::success;
case boost::system::errc::no_buffer_space:
return nano::stat::detail::no_buffer_space;
case boost::system::errc::timed_out:
return nano::stat::detail::timed_out;
case boost::system::errc::host_unreachable:
return nano::stat::detail::host_unreachable;
case boost::system::errc::not_supported:
return nano::stat::detail::not_supported;
default:
return nano::stat::detail::other;
}
}

View file

@ -25,3 +25,8 @@ bool is_same_subnetwork (boost::asio::ip::address const &, boost::asio::ip::addr
// Unassigned, reserved, self
bool reserved_address (nano::endpoint const &, bool allow_local_peers = false);
}
namespace nano
{
nano::stat::detail to_stat_detail (boost::system::error_code const &);
}