Emit 256 bits of random on RPC server subscribe.

This commit is contained in:
Arthur Britto
2012-12-06 00:02:02 -08:00
parent 10ba85a493
commit de9cffe5c5
3 changed files with 20 additions and 7 deletions

View File

@@ -1307,8 +1307,24 @@ bool NetworkOPs::unsubLedger(InfoSub* ispListener)
// <-- bool: true=added, false=already there
bool NetworkOPs::subServer(InfoSub* ispListener, Json::Value& jvResult)
{
uint256 uRandom;
jvResult["stand_alone"] = theConfig.RUN_STANDALONE;
switch (RAND_bytes(uRandom.begin(), uRandom.size()))
{
case 0:
case 1:
jvResult["random"] = uRandom.ToString();
break;
case -1:
default:
// XXX Should probably stop running.
cLog(lsFATAL) << "Internal error: unable to generate secure random.";
break;
}
return mSubServer.insert(ispListener).second;
}