-
Notifications
You must be signed in to change notification settings - Fork 792
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Networking cleanup continued (#4495)
* Organize * Renamings * Dedicated thread for tcp keepalives * Rename 'reachout' to `track_reachout` * Dedicated network reachout thread * Merge tcp channels and network keepalive loops * Unused * Random number generator helper * Properly close channel container * Rework channel purging * Reverse track_reachout return value * Rework `add_initial_peers` * Stop network component last
- Loading branch information
1 parent
5891121
commit 9b38bb2
Showing
18 changed files
with
357 additions
and
254 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#pragma once | ||
|
||
#include <random> | ||
|
||
namespace nano | ||
{ | ||
/** | ||
* Not safe for any crypto related code, use for non-crypto PRNG only. | ||
*/ | ||
class random_generator final | ||
{ | ||
public: | ||
/// Generate a random number in the range [min, max) | ||
auto random (auto min, auto max) | ||
{ | ||
release_assert (min < max); | ||
std::uniform_int_distribution<decltype (min)> dist (min, max - 1); | ||
return dist (rng); | ||
} | ||
|
||
/// Generate a random number in the range [0, max) | ||
auto random (auto max) | ||
{ | ||
return random (decltype (max){ 0 }, max); | ||
} | ||
|
||
private: | ||
std::random_device device; | ||
std::default_random_engine rng{ device () }; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -47,6 +47,7 @@ enum class name | |
rep_tiers, | ||
network_cleanup, | ||
network_keepalive, | ||
network_reachout, | ||
}; | ||
|
||
/* | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.