Cleanups and fixes.

This commit is contained in:
JoelKatz
2012-09-07 22:21:07 -07:00
parent 0defc8d5ab
commit 63921c9757
8 changed files with 28 additions and 32 deletions

View File

@@ -71,11 +71,11 @@ void HashedObjectStore::bulkWrite()
char type;
switch(it->getType())
{
case LEDGER: type = 'L'; break;
case TRANSACTION: type = 'T'; break;
case ACCOUNT_NODE: type = 'A'; break;
case TRANSACTION_NODE: type = 'N'; break;
default: type = 'U';
case hotLEDGER: type= 'L'; break;
case hotTRANSACTION: type = 'T'; break;
case hotACCOUNT_NODE: type = 'A'; break;
case hotTRANSACTION_NODE: type = 'N'; break;
default: type = 'U';
}
std::string rawData;
db->escape(&(it->getData().front()), it->getData().size(), rawData);
@@ -128,13 +128,13 @@ HashedObject::pointer HashedObjectStore::retrieve(const uint256& hash)
assert(Serializer::getSHA512Half(data) == hash);
HashedObjectType htype = UNKNOWN;
HashedObjectType htype = hotUNKNOWN;
switch (type[0])
{
case 'L': htype = LEDGER; break;
case 'T': htype = TRANSACTION; break;
case 'A': htype = ACCOUNT_NODE; break;
case 'N': htype = TRANSACTION_NODE; break;
case 'L': htype = hotLEDGER; break;
case 'T': htype = hotTRANSACTION; break;
case 'A': htype = hotACCOUNT_NODE; break;
case 'N': htype = hotTRANSACTION_NODE; break;
default:
Log(lsERROR) << "Invalid hashed object";
return HashedObject::pointer();

View File

@@ -10,11 +10,11 @@
enum HashedObjectType
{
UNKNOWN = 0,
LEDGER = 1,
TRANSACTION = 2,
ACCOUNT_NODE = 3,
TRANSACTION_NODE = 4
hotUNKNOWN = 0,
hotLEDGER = 1,
hotTRANSACTION = 2,
hotACCOUNT_NODE = 3,
hotTRANSACTION_NODE = 4
};
class HashedObject

View File

@@ -279,9 +279,9 @@ void Ledger::saveAcceptedLedger(Ledger::ref ledger)
ledger->mAccountHash.GetHex() % ledger->mTransHash.GetHex()));
// write out dirty nodes
while(ledger->mTransactionMap->flushDirty(256, TRANSACTION_NODE, ledger->mLedgerSeq))
while(ledger->mTransactionMap->flushDirty(256, hotTRANSACTION_NODE, ledger->mLedgerSeq))
{ ; }
while(ledger->mAccountStateMap->flushDirty(256, ACCOUNT_NODE, ledger->mLedgerSeq))
while(ledger->mAccountStateMap->flushDirty(256, hotACCOUNT_NODE, ledger->mLedgerSeq))
{ ; }
ledger->disarmDirty();

View File

@@ -310,7 +310,7 @@ bool LedgerAcquire::takeBase(const std::string& data)
Serializer s(data.size() + 4);
s.add32(sHP_Ledger);
s.addRaw(data);
theApp->getHashedObjectStore().store(LEDGER, mLedger->getLedgerSeq(), s.peekData(), mHash);
theApp->getHashedObjectStore().store(hotLEDGER, mLedger->getLedgerSeq(), s.peekData(), mHash);
progress();
if (!mLedger->getTransHash())

View File

@@ -37,7 +37,7 @@ public:
virtual void gotNode(const SHAMapNode& id, const uint256& nodeHash,
const std::vector<unsigned char>& nodeData, bool isLeaf)
{
theApp->getHashedObjectStore().store(ACCOUNT_NODE, mLedgerSeq, nodeData, nodeHash);
theApp->getHashedObjectStore().store(hotACCOUNT_NODE, mLedgerSeq, nodeData, nodeHash);
}
virtual bool haveNode(const SHAMapNode& id, const uint256& nodeHash, std::vector<unsigned char>& nodeData)
{ // fetchNodeExternal already tried
@@ -58,7 +58,8 @@ public:
virtual void gotNode(const SHAMapNode& id, const uint256& nodeHash,
const std::vector<unsigned char>& nodeData, bool isLeaf)
{
theApp->getHashedObjectStore().store(isLeaf ? TRANSACTION : TRANSACTION_NODE, mLedgerSeq, nodeData, nodeHash);
theApp->getHashedObjectStore().store(isLeaf ? hotTRANSACTION : hotTRANSACTION_NODE, mLedgerSeq,
nodeData, nodeHash);
}
virtual bool haveNode(const SHAMapNode& id, const uint256& nodeHash, std::vector<unsigned char>& nodeData)
{ // fetchNodeExternal already tried

View File

@@ -71,7 +71,7 @@ protected:
uint32 mPrevLgrSeq;
public:
TMNEThread() : TransactionMetaNodeEntry(TMSThread) { ; }
TMNEThread() : TransactionMetaNodeEntry(TMSThread), mPrevLgrSeq(0) { ; }
TMNEThread(uint256 prevTx, uint32 prevLgrSeq)
: TransactionMetaNodeEntry(TMSThread), mPrevTxID(prevTx), mPrevLgrSeq(prevLgrSeq)
{ ; }

View File

@@ -184,8 +184,6 @@ void UniqueNodeList::scoreCompute()
Database* db=theApp->getWalletDB()->getDB();
std::string strSql;
// For each entry in SeedDomains with a PublicKey:
// - Add an entry in umPulicIdx, umDomainIdx, and vsnNodes.
{
@@ -389,7 +387,7 @@ void UniqueNodeList::scoreCompute()
db->executeSQL("BEGIN;");
db->executeSQL("UPDATE TrustedNodes SET Score = 0 WHERE Score != 0;");
if (vsnNodes.size())
if (!vsnNodes.empty())
{
// Load existing Seens from DB.
std::vector<std::string> vstrPublicKeys;
@@ -410,7 +408,7 @@ void UniqueNodeList::scoreCompute()
boost::unordered_set<std::string> usUNL;
if (vsnNodes.size())
if (!vsnNodes.empty())
{
// Update the score old entries and add new entries as needed.
std::vector<std::string> vstrValues;
@@ -446,7 +444,7 @@ void UniqueNodeList::scoreCompute()
boost::unordered_map<std::string, int> umValidators;
if (vsnNodes.size())
if (!vsnNodes.empty())
{
std::vector<std::string> vstrPublicKeys;
@@ -627,7 +625,7 @@ void UniqueNodeList::processIps(const std::string& strSite, const NewcoinAddress
}
// Add new referral entries.
if (pmtVecStrIps && pmtVecStrIps->size()) {
if (pmtVecStrIps && !pmtVecStrIps->empty()) {
std::vector<std::string> vstrValues;
vstrValues.resize(MIN(pmtVecStrIps->size(), REFERRAL_IPS_MAX));
@@ -712,7 +710,6 @@ int UniqueNodeList::processValidators(const std::string& strSite, const std::str
break;
boost::smatch smMatch;
std::string strIP;
// domain comment?
// public_key comment?

View File

@@ -16,8 +16,8 @@
#include "Application.h"
#include "utils.h"
Wallet::Wallet() : mLedger(0) {
}
Wallet::Wallet() : mDh512(NULL), mDh1024(NULL), mLedger(0)
{ ; }
void Wallet::start()
{
@@ -136,8 +136,6 @@ bool Wallet::dataFetch(const std::string& strKey, std::string& strValue)
if (db->executeSQL(str(boost::format("SELECT Value FROM RPCData WHERE Key=%s;")
% db->escape(strKey))) && db->startIterRows())
{
std::string strPublicKey, strPrivateKey;
std::vector<unsigned char> vucData = db->getBinary("Value");
strValue.assign(vucData.begin(), vucData.end());