Improve pool seeding during startup:

* When starting up, we no longer rely just on the standard
  system RNG to generate entropy: we attempt to squeeze some
  from the execution state, and to recover any entropy that
  we had previously stored.

* When shutting down, if sufficient entropy has been accumulated
  attempt to store it for future use.
This commit is contained in:
Nik Bougalis
2015-02-17 19:14:01 -08:00
committed by Tom Ritchford
parent 382a16ff07
commit 84e618b3f2
5 changed files with 79 additions and 4 deletions

View File

@@ -62,6 +62,7 @@
#include <ripple/validators/make_Manager.h>
#include <ripple/unity/git_id.h>
#include <ripple/websocket/MakeServer.h>
#include <ripple/crypto/RandomNumbers.h>
#include <beast/asio/io_latency_probe.h>
#include <beast/module/core/text/LexicalCast.h>
#include <beast/module/core/thread/DeadlineTimer.h>
@@ -286,6 +287,7 @@ public:
std::unique_ptr <Validations> mValidations;
std::unique_ptr <LoadManager> m_loadManager;
beast::DeadlineTimer m_sweepTimer;
beast::DeadlineTimer m_entropyTimer;
std::unique_ptr <DatabaseCon> mRpcDB;
std::unique_ptr <DatabaseCon> mTxnDB;
@@ -408,6 +410,8 @@ public:
, m_sweepTimer (this)
, m_entropyTimer (this)
, m_signals(get_io_service(), SIGINT)
, m_resolver (ResolverAsio::New (get_io_service(), m_logs.journal("Resolver")))
@@ -857,6 +861,7 @@ public:
m_journal.info << "Application starting. Build is " << gitCommitID();
m_sweepTimer.setExpiration (10);
m_entropyTimer.setRecurringExpiration (300);
m_io_latency_sampler.start();
@@ -887,6 +892,8 @@ public:
m_sweepTimer.cancel ();
m_entropyTimer.cancel ();
mValidations->flush ();
RippleAddress::clearCache ();
@@ -952,6 +959,12 @@ public:
void onDeadlineTimer (beast::DeadlineTimer& timer)
{
if (timer == m_entropyTimer)
{
add_entropy (nullptr, 0);
return;
}
if (timer == m_sweepTimer)
{
// VFALCO TODO Move all this into doSweep