mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-26 14:05:51 +00:00
Replace all Application nonces with nonce singleton and refactor hash_value functions
This commit is contained in:
@@ -68,10 +68,11 @@ Application::Application ()
|
||||
, mSweepTimer (mAuxService)
|
||||
, mShutdown (false)
|
||||
{
|
||||
RandomNumbers::getInstance ().fillBytes (mNonce256.begin(), mNonce256.size());
|
||||
RandomNumbers::getInstance ().fill (&mNonceST);
|
||||
// VFALCO: TODO, remove these once the call is thread safe.
|
||||
HashMaps::getInstance ().initializeNonce <size_t> ();
|
||||
}
|
||||
|
||||
|
||||
extern const char *RpcDBInit[], *TxnDBInit[], *LedgerDBInit[], *WalletDBInit[], *HashNodeDBInit[],
|
||||
*NetNodeDBInit[], *PathFindDBInit[];
|
||||
extern int RpcDBCount, TxnDBCount, LedgerDBCount, WalletDBCount, HashNodeDBCount,
|
||||
|
||||
@@ -79,9 +79,6 @@ class Application
|
||||
WSDoor* mWSPublicDoor;
|
||||
WSDoor* mWSPrivateDoor;
|
||||
|
||||
uint256 mNonce256;
|
||||
std::size_t mNonceST;
|
||||
|
||||
boost::asio::deadline_timer mSweepTimer;
|
||||
|
||||
std::map<std::string, Peer::pointer> mPeerMap;
|
||||
@@ -148,9 +145,6 @@ public:
|
||||
leveldb::DB* getHashNodeLDB() { return mHashNodeLDB; }
|
||||
leveldb::DB* getEphemeralLDB() { return mEphemeralLDB; }
|
||||
|
||||
uint256 getNonce256() { return mNonce256; }
|
||||
std::size_t getNonceST() { return mNonceST; }
|
||||
|
||||
bool isShutdown() { return mShutdown; }
|
||||
void setup();
|
||||
void run();
|
||||
|
||||
@@ -6,9 +6,6 @@
|
||||
#include <boost/thread/mutex.hpp>
|
||||
#include <boost/thread/condition_variable.hpp>
|
||||
|
||||
#include "ripple_HashValue.h"
|
||||
|
||||
|
||||
// VFALCO: TODO, Move this to someplace sensible!!
|
||||
// Adapter to furnish uptime information to KeyCache via UptimeTimer singleton
|
||||
struct UptimeTimerAdapter
|
||||
|
||||
@@ -24,11 +24,15 @@ DECLARE_INSTANCE(SHAMapTreeNode);
|
||||
|
||||
void SHAMapNode::setMHash() const
|
||||
{
|
||||
std::size_t h = theApp->getNonceST() + (mDepth * 0x9e3779b9);
|
||||
const unsigned int *ptr = reinterpret_cast<const unsigned int *>(mNodeID.begin());
|
||||
for (int i = (mDepth + 7) / 8; i != 0; --i)
|
||||
std::size_t h = HashMaps::getInstance ().getNonce <std::size_t> ()
|
||||
+ (mDepth * 0x9e3779b9);
|
||||
|
||||
const unsigned int *ptr = reinterpret_cast <const unsigned int *>(mNodeID.begin());
|
||||
|
||||
for (int i = (mDepth + 7) / 8; i != 0; --i)
|
||||
h = (h * 0x9e3779b9) ^ *ptr++;
|
||||
mHash = h;
|
||||
|
||||
mHash = h;
|
||||
}
|
||||
|
||||
std::size_t hash_value(const SHAMapNode& mn)
|
||||
|
||||
@@ -1,21 +0,0 @@
|
||||
|
||||
std::size_t hash_value(const uint256& u)
|
||||
{
|
||||
std::size_t seed = theApp->getNonceST();
|
||||
|
||||
return u.hash_combine(seed);
|
||||
}
|
||||
|
||||
std::size_t hash_value(const uint160& u)
|
||||
{
|
||||
std::size_t seed = theApp->getNonceST();
|
||||
|
||||
return u.hash_combine(seed);
|
||||
}
|
||||
|
||||
std::size_t hash_value(const CBase58Data& b58)
|
||||
{
|
||||
std::size_t seed = theApp->getNonceST() + (b58.nVersion * 0x9e3779b9);
|
||||
boost::hash_combine(seed, b58.vchData);
|
||||
return seed;
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
|
||||
#ifndef RIPPLE_HASH_VALUE_H
|
||||
#define RIPPLE_HASH_VALUE_H
|
||||
|
||||
// VFALCO: TODO, clean this up
|
||||
//
|
||||
// These are needed for boost::hash stuff. The implemnetations access
|
||||
// the Application object for the nonce, introducing a nasty dependency
|
||||
// so I have split them away from the relevant classes and put them here.
|
||||
|
||||
extern std::size_t hash_value(const uint160&);
|
||||
|
||||
extern std::size_t hash_value(const uint256&);
|
||||
|
||||
extern std::size_t hash_value(const CBase58Data& b58);
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user