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)
{
dropCache();
return;
}
if (theApp->getJobQueue().getJobCount(jtPUBOLDLEDGER) == 0)
theApp->getLedgerMaster().resumeAcquiring();

View File

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

View File

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

View File

@@ -674,11 +674,13 @@ bool NetworkOPs::checkLastClosedLedger(const std::vector<Peer::pointer>& peerLis
cLog(lsTRACE) << "NetworkOPs::checkLastClosedLedger";
Ledger::pointer ourClosed = mLedgerMaster->getClosedLedger();
if(!ourClosed)
if (!ourClosed)
return false;
uint256 closedLedger = ourClosed->getHash();
uint256 prevClosedLedger = ourClosed->getParentHash();
cLog(lsTRACE) << "OurClosed: " << closedLedger;
cLog(lsTRACE) << "PrevClosed: " << prevClosedLedger;
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::string sql =
str(boost::format("SELECT LedgerSeq,Status,RawTxn,TxnMeta FROM Transactions where TransID in "
"(SELECT TransID from AccountTransactions "
" WHERE Account = '%s' AND LedgerSeq <= '%u' AND LedgerSeq >= '%u' ) ORDER BY LedgerSeq DESC LIMIT 200;")
str(boost::format("SELECT AccountTransactions.LedgerSeq,Status,RawTxn,TxnMeta FROM "
"AccountTransactions INNER JOIN Transactions ON Transactions.TransID = AccountTransactions.TransID "
"WHERE Account = '%s' AND AccountTransactions.LedgerSeq <= '%u' AND AccountTransactions.LedgerSeq >= '%u' "
"ORDER BY AccountTransactions.LedgerSeq DESC LIMIT 200;")
% account.humanAccountID() % maxLedger % minLedger);
{
@@ -1099,9 +1102,10 @@ std::vector<NetworkOPs::txnMetaLedgerType> NetworkOPs::getAccountTxsB(
{ // can be called with no locks
std::vector< txnMetaLedgerType> ret;
std::string sql =
str(boost::format("SELECT LedgerSeq, RawTxn,TxnMeta FROM Transactions where TransID in (SELECT TransID from AccountTransactions "
" WHERE Account = '%s' AND LedgerSeq <= '%u' AND LedgerSeq >= '%u' ) ORDER BY LedgerSeq DESC LIMIT 500;")
std::string sql = str(boost::format("SELECT AccountTransactions.LedgerSeq,Status,RawTxn,TxnMeta FROM "
"AccountTransactions INNER JOIN Transactions ON Transactions.TransID = AccountTransactions.TransID "
"WHERE Account = '%s' AND AccountTransactions.LedgerSeq <= '%u' AND AccountTransactions.LedgerSeq >= '%u' "
"ORDER BY AccountTransactions.LedgerSeq DESC LIMIT 500;")
% account.humanAccountID() % maxLedger % minLedger);
{

View File

@@ -251,9 +251,10 @@ ValidationCollection::getCurrentValidations(uint256 currentLedger)
else
{ // contains a live record
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()];
++(p.first); // count for the favored ledger
++(p.first);
uint160 ni = it->second->getNodeID();
if (ni > p.second)
p.second = ni;