Skip to content

Commit

Permalink
Merge branch 'dev_tcp' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
clemahieu committed Mar 15, 2024
2 parents 2d08704 + e1d1517 commit ef985e3
Show file tree
Hide file tree
Showing 15 changed files with 290 additions and 216 deletions.
46 changes: 46 additions & 0 deletions nano/lib/logging.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,58 @@ using logger_id = std::pair<nano::log::type, nano::log::detail>;

std::string to_string (logger_id);
logger_id parse_logger_id (std::string const &);
}

// Time helpers
namespace nano::log
{
template <class Clock>
auto microseconds (std::chrono::time_point<Clock> time)
{
return std::chrono::duration_cast<std::chrono::microseconds> (time.time_since_epoch ()).count ();
}

template <class Duration>
auto microseconds (Duration duration)
{
return std::chrono::duration_cast<std::chrono::microseconds> (duration).count ();
}

template <class Clock>
auto milliseconds (std::chrono::time_point<Clock> time)
{
return std::chrono::duration_cast<std::chrono::milliseconds> (time.time_since_epoch ()).count ();
}

template <class Duration>
auto milliseconds (Duration duration)
{
return std::chrono::duration_cast<std::chrono::milliseconds> (duration).count ();
}

template <class Clock>
auto seconds (std::chrono::time_point<Clock> time)
{
return std::chrono::duration_cast<std::chrono::seconds> (time.time_since_epoch ()).count ();
}

template <class Duration>
auto seconds (Duration duration)
{
return std::chrono::duration_cast<std::chrono::seconds> (duration).count ();
}

template <class Clock>
auto milliseconds_delta (std::chrono::time_point<Clock> time, std::chrono::time_point<Clock> now = Clock::now ())
{
return std::chrono::duration_cast<std::chrono::milliseconds> (now - time).count ();
}

template <class Clock>
auto seconds_delta (std::chrono::time_point<Clock> time, std::chrono::time_point<Clock> now = Clock::now ())
{
return std::chrono::duration_cast<std::chrono::seconds> (now - time).count ();
}
}

namespace nano
Expand Down
1 change: 1 addition & 0 deletions nano/lib/logging_enums.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ enum class type
election_scheduler,
vote_generator,
rep_tiers,
syn_cookies,

// bootstrap
bulk_pull_client,
Expand Down
4 changes: 4 additions & 0 deletions nano/lib/stats_enums.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ enum class type : uint8_t
ledger,
rollback,
bootstrap,
network,
tcp_server,
vote,
election,
Expand Down Expand Up @@ -52,6 +53,7 @@ enum class type : uint8_t
rep_crawler,
local_block_broadcaster,
rep_tiers,
syn_cookies,

bootstrap_ascending,
bootstrap_ascending_accounts,
Expand All @@ -67,6 +69,8 @@ enum class detail : uint8_t
// common
ok,
loop,
loop_cleanup,
loop_keepalive,
total,
process,
processed,
Expand Down
6 changes: 6 additions & 0 deletions nano/lib/thread_roles.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,12 @@ std::string nano::thread_role::get_string (nano::thread_role::name role)
case nano::thread_role::name::rep_tiers:
thread_role_name_string = "Rep tiers";
break;
case nano::thread_role::name::network_cleanup:
thread_role_name_string = "Net cleanup";
break;
case nano::thread_role::name::network_keepalive:
thread_role_name_string = "Net keepalive";
break;
default:
debug_assert (false && "nano::thread_role::get_string unhandled thread role");
}
Expand Down
2 changes: 2 additions & 0 deletions nano/lib/thread_roles.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ enum class name
rep_crawler,
local_block_broadcasting,
rep_tiers,
network_cleanup,
network_keepalive,
};

/*
Expand Down
Loading

0 comments on commit ef985e3

Please sign in to comment.