Merge branch 'master' of github.com:jedmccaleb/NewCoin

This commit is contained in:
Arthur Britto
2013-03-11 18:59:36 -07:00
6 changed files with 17 additions and 23 deletions

View File

@@ -516,10 +516,7 @@ void Ledger::saveAcceptedLedger(Job&, bool fromConsensus)
} }
if (!fromConsensus) if (!fromConsensus)
{
dropCache(); dropCache();
return;
}
if (theApp->getJobQueue().getJobCount(jtPUBOLDLEDGER) == 0) if (theApp->getJobQueue().getJobCount(jtPUBOLDLEDGER) == 0)
theApp->getLedgerMaster().resumeAcquiring(); theApp->getLedgerMaster().resumeAcquiring();

View File

@@ -379,7 +379,8 @@ void LedgerConsensus::checkLCL()
typedef std::map<uint256, currentValidationCount>::value_type u256_cvc_pair; typedef std::map<uint256, currentValidationCount>::value_type u256_cvc_pair;
BOOST_FOREACH(u256_cvc_pair& it, vals) BOOST_FOREACH(u256_cvc_pair& it, vals)
if (it.second.first > netLgrCount) if ((it.second.first > netLgrCount) ||
((it.second.first == netLgrCount) && (it.first == mPrevLedgerHash)))
{ {
netLgr = it.first; netLgr = it.first;
netLgrCount = it.second.first; netLgrCount = it.second.first;

View File

@@ -46,6 +46,7 @@ void LedgerMaster::pushLedger(Ledger::pointer newLCL, Ledger::pointer newOL, boo
assert(newLCL->isClosed() && newLCL->isAccepted()); assert(newLCL->isClosed() && newLCL->isAccepted());
assert(!newOL->isClosed() && !newOL->isAccepted()); assert(!newOL->isClosed() && !newOL->isAccepted());
boost::recursive_mutex::scoped_lock ml(mLock);
if (newLCL->isAccepted()) if (newLCL->isAccepted())
{ {
assert(newLCL->isClosed()); assert(newLCL->isClosed());
@@ -191,14 +192,10 @@ void LedgerMaster::asyncAccept(Ledger::pointer ledger)
bool LedgerMaster::acquireMissingLedger(Ledger::ref origLedger, const uint256& ledgerHash, uint32 ledgerSeq) bool LedgerMaster::acquireMissingLedger(Ledger::ref origLedger, const uint256& ledgerHash, uint32 ledgerSeq)
{ // return: false = already gave up recently { // return: false = already gave up recently
if (mTooFast)
return true;
Ledger::pointer ledger = mLedgerHistory.getLedgerBySeq(ledgerSeq); Ledger::pointer ledger = mLedgerHistory.getLedgerBySeq(ledgerSeq);
if (ledger && (Ledger::getHashByIndex(ledgerSeq) == ledgerHash)) if (ledger && (Ledger::getHashByIndex(ledgerSeq) == ledgerHash))
{ {
cLog(lsTRACE) << "Ledger hash found in database"; cLog(lsTRACE) << "Ledger hash found in database";
mTooFast = true;
theApp->getJobQueue().addJob(jtPUBOLDLEDGER, "LedgerMaster::asyncAccept", theApp->getJobQueue().addJob(jtPUBOLDLEDGER, "LedgerMaster::asyncAccept",
boost::bind(&LedgerMaster::asyncAccept, this, ledger)); boost::bind(&LedgerMaster::asyncAccept, this, ledger));
return true; return true;
@@ -293,9 +290,6 @@ bool LedgerMaster::shouldAcquire(uint32 currentLedger, uint32 ledgerHistory, uin
void LedgerMaster::resumeAcquiring() void LedgerMaster::resumeAcquiring()
{ {
boost::recursive_mutex::scoped_lock ml(mLock); boost::recursive_mutex::scoped_lock ml(mLock);
if (!mTooFast)
return;
mTooFast = false;
if (mMissingLedger && mMissingLedger->isDone()) if (mMissingLedger && mMissingLedger->isDone())
mMissingLedger.reset(); mMissingLedger.reset();
@@ -396,7 +390,6 @@ void LedgerMaster::setFullLedger(Ledger::pointer ledger)
if (theApp->getJobQueue().getJobCount(jtPUBOLDLEDGER) > 2) if (theApp->getJobQueue().getJobCount(jtPUBOLDLEDGER) > 2)
{ {
mTooFast = true;
cLog(lsDEBUG) << "Too many pending ledger saves"; cLog(lsDEBUG) << "Too many pending ledger saves";
return; return;
} }
@@ -556,7 +549,6 @@ void LedgerMaster::tryPublish()
} }
} }
mTooFast = false;
if (!mPubLedgers.empty() && !mPubThread) if (!mPubLedgers.empty() && !mPubThread)
{ {
theApp->getOPs().clearNeedNetworkLedger(); theApp->getOPs().clearNeedNetworkLedger();

View File

@@ -37,7 +37,6 @@ protected:
RangeSet mCompleteLedgers; RangeSet mCompleteLedgers;
LedgerAcquire::pointer mMissingLedger; LedgerAcquire::pointer mMissingLedger;
uint32 mMissingSeq; uint32 mMissingSeq;
bool mTooFast; // We are acquiring faster than we're writing
int mMinValidations; // The minimum validations to publish a ledger int mMinValidations; // The minimum validations to publish a ledger
uint256 mLastValidateHash; uint256 mLastValidateHash;
@@ -58,7 +57,7 @@ protected:
public: public:
LedgerMaster() : mHeldTransactions(uint256()), mMissingSeq(0), mTooFast(false), LedgerMaster() : mHeldTransactions(uint256()), mMissingSeq(0),
mMinValidations(0), mLastValidateSeq(0), mPubThread(false) mMinValidations(0), mLastValidateSeq(0), mPubThread(false)
{ ; } { ; }

View File

@@ -679,6 +679,8 @@ bool NetworkOPs::checkLastClosedLedger(const std::vector<Peer::pointer>& peerLis
uint256 closedLedger = ourClosed->getHash(); uint256 closedLedger = ourClosed->getHash();
uint256 prevClosedLedger = ourClosed->getParentHash(); uint256 prevClosedLedger = ourClosed->getParentHash();
cLog(lsTRACE) << "OurClosed: " << closedLedger;
cLog(lsTRACE) << "PrevClosed: " << prevClosedLedger;
boost::unordered_map<uint256, ValidationCount> ledgers; boost::unordered_map<uint256, ValidationCount> ledgers;
{ {
@@ -1063,9 +1065,10 @@ std::vector< std::pair<Transaction::pointer, TransactionMetaSet::pointer> >
std::vector< std::pair<Transaction::pointer, TransactionMetaSet::pointer> > ret; std::vector< std::pair<Transaction::pointer, TransactionMetaSet::pointer> > ret;
std::string sql = std::string sql =
str(boost::format("SELECT LedgerSeq,Status,RawTxn,TxnMeta FROM Transactions where TransID in " str(boost::format("SELECT AccountTransactions.LedgerSeq,Status,RawTxn,TxnMeta FROM "
"(SELECT TransID from AccountTransactions " "AccountTransactions INNER JOIN Transactions ON Transactions.TransID = AccountTransactions.TransID "
" WHERE Account = '%s' AND LedgerSeq <= '%u' AND LedgerSeq >= '%u' ) ORDER BY LedgerSeq DESC LIMIT 200;") "WHERE Account = '%s' AND AccountTransactions.LedgerSeq <= '%u' AND AccountTransactions.LedgerSeq >= '%u' "
"ORDER BY AccountTransactions.LedgerSeq DESC LIMIT 200;")
% account.humanAccountID() % maxLedger % minLedger); % account.humanAccountID() % maxLedger % minLedger);
{ {
@@ -1099,9 +1102,10 @@ std::vector<NetworkOPs::txnMetaLedgerType> NetworkOPs::getAccountTxsB(
{ // can be called with no locks { // can be called with no locks
std::vector< txnMetaLedgerType> ret; std::vector< txnMetaLedgerType> ret;
std::string sql = std::string sql = str(boost::format("SELECT AccountTransactions.LedgerSeq,Status,RawTxn,TxnMeta FROM "
str(boost::format("SELECT LedgerSeq, RawTxn,TxnMeta FROM Transactions where TransID in (SELECT TransID from AccountTransactions " "AccountTransactions INNER JOIN Transactions ON Transactions.TransID = AccountTransactions.TransID "
" WHERE Account = '%s' AND LedgerSeq <= '%u' AND LedgerSeq >= '%u' ) ORDER BY LedgerSeq DESC LIMIT 500;") "WHERE Account = '%s' AND AccountTransactions.LedgerSeq <= '%u' AND AccountTransactions.LedgerSeq >= '%u' "
"ORDER BY AccountTransactions.LedgerSeq DESC LIMIT 500;")
% account.humanAccountID() % maxLedger % minLedger); % account.humanAccountID() % maxLedger % minLedger);
{ {

View File

@@ -251,9 +251,10 @@ ValidationCollection::getCurrentValidations(uint256 currentLedger)
else else
{ // contains a live record { // contains a live record
bool countPreferred = valCurrentLedger && it->second->isPreviousHash(currentLedger); bool countPreferred = valCurrentLedger && it->second->isPreviousHash(currentLedger);
tLog(countPreferred, lsDEBUG) << "Counting for " << currentLedger << " not " << it->second->getLedgerHash();
currentValidationCount& p = countPreferred ? ret[currentLedger] : ret[it->second->getLedgerHash()]; currentValidationCount& p = countPreferred ? ret[currentLedger] : ret[it->second->getLedgerHash()];
++(p.first); // count for the favored ledger ++(p.first);
uint160 ni = it->second->getNodeID(); uint160 ni = it->second->getNodeID();
if (ni > p.second) if (ni > p.second)
p.second = ni; p.second = ni;