mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-03 17:35:51 +00:00
Emit 256 bits of random on RPC server subscribe.
This commit is contained in:
@@ -774,14 +774,13 @@ SLE::pointer Ledger::getASNode(LedgerStateParms& parms, const uint256& nodeID,
|
||||
if ( (parms & lepCREATE) == 0 )
|
||||
{
|
||||
parms = lepMISSING;
|
||||
cLog(lsDEBUG) << "getASNode: MISSING";
|
||||
|
||||
return SLE::pointer();
|
||||
}
|
||||
|
||||
parms = parms | lepCREATED | lepOKAY;
|
||||
SLE::pointer sle=boost::make_shared<SLE>(let, nodeID);
|
||||
|
||||
cLog(lsDEBUG) << "getASNode: CREATED";
|
||||
return sle;
|
||||
}
|
||||
|
||||
@@ -790,14 +789,12 @@ cLog(lsDEBUG) << "getASNode: CREATED";
|
||||
|
||||
if (sle->getType() != let)
|
||||
{ // maybe it's a currency or something
|
||||
cLog(lsDEBUG) << "getASNode: WRONG TYPE";
|
||||
parms = parms | lepWRONGTYPE;
|
||||
return SLE::pointer();
|
||||
}
|
||||
|
||||
parms = parms | lepOKAY;
|
||||
|
||||
cLog(lsDEBUG) << "getASNode: FOUND";
|
||||
return sle;
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -658,13 +658,13 @@ Json::Value RPCHandler::doAccountOffers(Json::Value jvRequest)
|
||||
|
||||
// Result:
|
||||
// {
|
||||
// random: <uint160>
|
||||
// random: <uint256>
|
||||
// }
|
||||
Json::Value RPCHandler::doRandom(Json::Value jvRequest)
|
||||
{
|
||||
uint160 uRandom;
|
||||
uint256 uRandom;
|
||||
|
||||
switch (RAND_pseudo_bytes(uRandom.begin(), uRandom.size()))
|
||||
switch (RAND_bytes(uRandom.begin(), uRandom.size()))
|
||||
{
|
||||
case 0:
|
||||
case 1:
|
||||
|
||||
Reference in New Issue
Block a user