mirror of
https://github.com/Xahau/xahaud.git
synced 2025-12-06 17:27:52 +00:00
style improvements
This commit is contained in:
@@ -9,21 +9,21 @@
|
|||||||
|
|
||||||
bool HashedObject::checkHash() const
|
bool HashedObject::checkHash() const
|
||||||
{
|
{
|
||||||
uint256 hash=Serializer::getSHA512Half(mData);
|
uint256 hash = Serializer::getSHA512Half(mData);
|
||||||
return hash==mHash;
|
return hash == mHash;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool HashedObject::checkFixHash()
|
bool HashedObject::checkFixHash()
|
||||||
{
|
{
|
||||||
uint256 hash=Serializer::getSHA512Half(mData);
|
uint256 hash = Serializer::getSHA512Half(mData);
|
||||||
if(hash==mHash) return true;
|
if (hash == mHash) return true;
|
||||||
mHash=hash;
|
mHash = hash;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void HashedObject::setHash()
|
void HashedObject::setHash()
|
||||||
{
|
{
|
||||||
mHash=Serializer::getSHA512Half(mData);
|
mHash = Serializer::getSHA512Half(mData);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -39,12 +39,12 @@ CREATE INDEX ObjectLocate ON CommittedObjects(LedgerIndex, ObjType);
|
|||||||
bool HashedObject::store(HashedObjectType type, uint32 index, const std::vector<unsigned char>& data,
|
bool HashedObject::store(HashedObjectType type, uint32 index, const std::vector<unsigned char>& data,
|
||||||
const uint256& hash)
|
const uint256& hash)
|
||||||
{
|
{
|
||||||
if(!theApp->getHashNodeDB()) return true;
|
if (!theApp->getHashNodeDB()) return true;
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
Serializer s(data);
|
Serializer s(data);
|
||||||
assert(hash==s.getSHA512Half());
|
assert(hash == s.getSHA512Half());
|
||||||
#endif
|
#endif
|
||||||
std::string sql="INSERT INTO CommitedObjects (Hash,ObjType,LedgerIndex,Object) VALUES ('";
|
std::string sql = "INSERT INTO CommitedObjects (Hash,ObjType,LedgerIndex,Object) VALUES ('";
|
||||||
sql.append(hash.GetHex());
|
sql.append(hash.GetHex());
|
||||||
switch(type)
|
switch(type)
|
||||||
{
|
{
|
||||||
@@ -63,7 +63,7 @@ bool HashedObject::store(HashedObjectType type, uint32 index, const std::vector<
|
|||||||
sql.append(");");
|
sql.append(");");
|
||||||
|
|
||||||
ScopedLock sl(theApp->getHashNodeDB()->getDBLock());
|
ScopedLock sl(theApp->getHashNodeDB()->getDBLock());
|
||||||
Database* db=theApp->getHashNodeDB()->getDB();
|
Database* db = theApp->getHashNodeDB()->getDB();
|
||||||
return db->executeSQL(sql);
|
return db->executeSQL(sql);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -77,8 +77,8 @@ bool HashedObject::store() const
|
|||||||
|
|
||||||
HashedObject::pointer HashedObject::retrieve(const uint256& hash)
|
HashedObject::pointer HashedObject::retrieve(const uint256& hash)
|
||||||
{
|
{
|
||||||
if(!theApp->getHashNodeDB()) return HashedObject::pointer();
|
if (!theApp->getHashNodeDB()) return HashedObject::pointer();
|
||||||
std::string sql="SELECT * from CommitedObjects WHERE Hash='";
|
std::string sql = "SELECT * from CommitedObjects WHERE Hash='";
|
||||||
sql.append(hash.GetHex());
|
sql.append(hash.GetHex());
|
||||||
sql.append("';");
|
sql.append("';");
|
||||||
|
|
||||||
@@ -89,37 +89,38 @@ HashedObject::pointer HashedObject::retrieve(const uint256& hash)
|
|||||||
|
|
||||||
{
|
{
|
||||||
ScopedLock sl(theApp->getHashNodeDB()->getDBLock());
|
ScopedLock sl(theApp->getHashNodeDB()->getDBLock());
|
||||||
Database* db=theApp->getHashNodeDB()->getDB();
|
Database* db = theApp->getHashNodeDB()->getDB();
|
||||||
|
|
||||||
if(!db->executeSQL(sql) || !db->startIterRows())
|
if (!db->executeSQL(sql) || !db->startIterRows())
|
||||||
return HashedObject::pointer();
|
return HashedObject::pointer();
|
||||||
|
|
||||||
std::string type;
|
std::string type;
|
||||||
db->getStr("ObjType", type);
|
db->getStr("ObjType", type);
|
||||||
if(type.size()==0) return HashedObject::pointer();
|
if (type.size() == 0) return HashedObject::pointer();
|
||||||
|
|
||||||
index=db->getBigInt("LedgerIndex");
|
index = db->getBigInt("LedgerIndex");
|
||||||
|
|
||||||
int size=db->getBinary("Object", NULL, 0);
|
int size = db->getBinary("Object", NULL, 0);
|
||||||
data.resize(size);
|
data.resize(size);
|
||||||
db->getBinary("Object", &(data.front()), size);
|
db->getBinary("Object", &(data.front()), size);
|
||||||
db->endIterRows();
|
db->endIterRows();
|
||||||
}
|
}
|
||||||
|
|
||||||
HashedObjectType htype=UNKNOWN;
|
HashedObjectType htype = UNKNOWN;
|
||||||
switch(type[0])
|
switch(type[0])
|
||||||
{
|
{
|
||||||
case 'L': htype=LEDGER; break;
|
case 'L': htype = LEDGER; break;
|
||||||
case 'T': htype=TRANSACTION; break;
|
case 'T': htype = TRANSACTION; break;
|
||||||
case 'A': htype=ACCOUNT_NODE; break;
|
case 'A': htype = ACCOUNT_NODE; break;
|
||||||
case 'N': htype=TRANSACTION_NODE; break;
|
case 'N': htype = TRANSACTION_NODE; break;
|
||||||
}
|
}
|
||||||
|
|
||||||
HashedObject::pointer obj(new HashedObject(htype, index, data));
|
HashedObject::pointer obj = boost::make_shared<HashedObject>(htype, index, data);
|
||||||
obj->mHash=hash;
|
obj->mHash = hash;
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
assert(obj->checkHash());
|
assert(obj->checkHash());
|
||||||
#endif
|
#endif
|
||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
// vim:ts=4
|
// vim:ts=4
|
||||||
|
|||||||
Reference in New Issue
Block a user