mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 17:27:55 +00:00
Optimizations.
This commit is contained in:
@@ -5,6 +5,8 @@
|
|||||||
#include <boost/foreach.hpp>
|
#include <boost/foreach.hpp>
|
||||||
#include <boost/lexical_cast.hpp>
|
#include <boost/lexical_cast.hpp>
|
||||||
|
|
||||||
|
#include <openssl/sha.h>
|
||||||
|
|
||||||
std::string SHAMapNode::getString() const
|
std::string SHAMapNode::getString() const
|
||||||
{
|
{
|
||||||
std::string ret="NodeID(";
|
std::string ret="NodeID(";
|
||||||
@@ -363,20 +365,20 @@ const uint256& SHAMapInnerNode::getChildHash(int m) const
|
|||||||
return mHashes[m];
|
return mHashes[m];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool SHAMapInnerNode::isEmpty() const
|
||||||
|
{
|
||||||
|
for(int i=0; i<32; i++)
|
||||||
|
if(mHashes[i]!=0) return false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
bool SHAMapInnerNode::updateHash()
|
bool SHAMapInnerNode::updateHash()
|
||||||
{
|
{
|
||||||
int nc=0;
|
uint256 j[2];
|
||||||
Serializer s(1024);
|
if(!isEmpty())
|
||||||
for(int i=0; i<32; i++)
|
SHA512(reinterpret_cast<unsigned char *>(mHashes), sizeof(mHashes), (unsigned char *) j);
|
||||||
{
|
if(mHash==j[0]) return false;
|
||||||
if(mHashes[i]!=0) nc++;
|
mHash=j[0];
|
||||||
s.add256(mHashes[i]);
|
|
||||||
}
|
|
||||||
uint256 nh=0;
|
|
||||||
if(nc!=0)
|
|
||||||
nh=s.getSHA512Half();
|
|
||||||
if(mHash==nh) return false;
|
|
||||||
mHash=nh;
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user