Bugfixes.

This commit is contained in:
JoelKatz
2012-06-24 06:31:03 -07:00
parent 29586c8e7d
commit 324992b2ad
5 changed files with 25 additions and 22 deletions

View File

@@ -37,7 +37,7 @@ DatabaseCon::~DatabaseCon()
Application::Application() :
mUNL(mIOService),
mNetOps(mIOService, &mMasterLedger), mNodeCache(16384, 600), mHashedObjectStore(16384, 300),
mNetOps(mIOService, &mMasterLedger), mTempNodeCache(16384, 90), mHashedObjectStore(16384, 300),
mTxnDB(NULL), mLedgerDB(NULL), mWalletDB(NULL), mHashNodeDB(NULL), mNetNodeDB(NULL),
mConnectionPool(mIOService), mPeerDoor(NULL), mRPCDoor(NULL)
{

View File

@@ -46,7 +46,7 @@ class Application
LedgerAcquireMaster mMasterLedgerAcquire;
TransactionMaster mMasterTransaction;
NetworkOPs mNetOps;
NodeCache mNodeCache;
NodeCache mTempNodeCache;
ValidationCollection mValidations;
SuppressionTable mSuppressions;
HashedObjectStore mHashedObjectStore;
@@ -80,7 +80,7 @@ public:
LedgerMaster& getMasterLedger() { return mMasterLedger; }
LedgerAcquireMaster& getMasterLedgerAcquire() { return mMasterLedgerAcquire; }
TransactionMaster& getMasterTransaction() { return mMasterTransaction; }
NodeCache& getNodeCache() { return mNodeCache; }
NodeCache& getTempNodeCache() { return mTempNodeCache; }
HashedObjectStore& getHashedObjectStore() { return mHashedObjectStore; }
ValidationCollection& getValidations() { return mValidations; }
bool isNew(const uint256& s) { return mSuppressions.addSuppression(s); }

View File

@@ -5,6 +5,8 @@
#include <boost/lexical_cast.hpp>
#include <boost/make_shared.hpp>
#include "../json/writer.h"
#include "Application.h"
#include "Ledger.h"
#include "utils.h"
@@ -350,6 +352,11 @@ Ledger::pointer Ledger::getSQL(const std::string& sql)
boost::make_shared<Ledger>(prevHash, transHash, accountHash, totCoins, closingTime, ledgerSeq);
if (ret->getHash() != ledgerHash)
{
Json::StyledStreamWriter ssw;
Log(lsERROR) << "Failed on ledger";
Json::Value p;
ret->addJson(p, LEDGER_JSON_FULL);
ssw.write(Log(lsERROR).ref(), p);
assert(false);
return Ledger::pointer();
}
@@ -379,7 +386,8 @@ void Ledger::addJson(Json::Value& ret, int options)
boost::recursive_mutex::scoped_lock sl(mLock);
ledger["parentHash"] = mParentHash.GetHex();
if(mClosed)
bool full = (options & LEDGER_JSON_FULL) != 0;
if(mClosed || full)
{
ledger["hash"] = mHash.GetHex();
ledger["transactionHash"] = mTransHash.GetHex();
@@ -391,8 +399,7 @@ void Ledger::addJson(Json::Value& ret, int options)
else ledger["closed"] = false;
if (mCloseTime != 0)
ledger["closeTime"] = boost::posix_time::to_simple_string(ptFromSeconds(mCloseTime));
bool full = (options & LEDGER_JSON_FULL) != 0;
if (full || ((options & LEDGER_JSON_DUMP_TXNS) != 0))
if (mTransactionMap && (full || ((options & LEDGER_JSON_DUMP_TXNS) != 0)))
{
Json::Value txns(Json::arrayValue);
for (SHAMapItem::pointer item = mTransactionMap->peekFirstItem(); !!item;
@@ -408,7 +415,7 @@ void Ledger::addJson(Json::Value& ret, int options)
}
ledger["transactions"] = txns;
}
if (full || ((options & LEDGER_JSON_DUMP_STATE) != 0))
if (mAccountStateMap && (full || ((options & LEDGER_JSON_DUMP_STATE) != 0)))
{
Json::Value state(Json::arrayValue);
for (SHAMapItem::pointer item = mAccountStateMap->peekFirstItem(); !!item;

View File

@@ -60,9 +60,11 @@ Ledger::pointer LedgerHistory::getLedgerByHash(const uint256& hash)
Ledger::pointer ret = mLedgersByHash.fetch(hash);
if (ret) return ret;
ret = Ledger::loadByHash(hash);
if (!ret) return ret;
assert(ret->getHash() == hash);
// FIXME: A ledger without SHA maps isn't very useful
// This code will need to build them
// ret = Ledger::loadByHash(hash);
// if (!ret) return ret;
// assert(ret->getHash() == hash);
boost::recursive_mutex::scoped_lock sl(mLedgersByHash.peekMutex());
mLedgersByHash.canonicalize(hash, ret);

View File

@@ -15,12 +15,12 @@ public:
const std::vector<unsigned char>& nodeData, bool isLeaf)
{
// WRITEME: If 'isLeaf' is true, this is a transaction
theApp->getNodeCache().store(nodeHash, nodeData);
theApp->getTempNodeCache().store(nodeHash, nodeData);
}
virtual bool haveNode(const SHAMapNode& id, const uint256& nodeHash, std::vector<unsigned char>& nodeData)
{
// WRITEME: We could check our own map, we could check transaction tables
return theApp->getNodeCache().retrieve(nodeHash, nodeData);
return theApp->getTempNodeCache().retrieve(nodeHash, nodeData);
}
};
@@ -40,11 +40,8 @@ public:
theApp->getHashedObjectStore().store(ACCOUNT_NODE, mLedgerSeq, nodeData, nodeHash);
}
virtual bool haveNode(const SHAMapNode& id, const uint256& nodeHash, std::vector<unsigned char>& nodeData)
{
HashedObject::pointer node = theApp->getHashedObjectStore().retrieve(nodeHash);
if (!node) return false;
nodeData = node->getData();
return true;
{ // fetchNode already tried
return false;
}
};
@@ -64,11 +61,8 @@ public:
theApp->getHashedObjectStore().store(isLeaf ? TRANSACTION : TRANSACTION_NODE, mLedgerSeq, nodeData, nodeHash);
}
virtual bool haveNode(const SHAMapNode& id, const uint256& nodeHash, std::vector<unsigned char>& nodeData)
{
HashedObject::pointer node = theApp->getHashedObjectStore().retrieve(nodeHash);
if (!node) return false;
nodeData = node->getData();
return true;
{ // fetchNode already tried
return false;
}
};