mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-27 14:35:52 +00:00
Merge branch 'master' of github.com:jedmccaleb/NewCoin
This commit is contained in:
@@ -88,10 +88,7 @@ Ledger::Ledger(bool /* dummy */, Ledger& prevLedger) :
|
||||
mCloseResolution = ContinuousLedgerTiming::getNextLedgerTimeResolution(prevLedger.mCloseResolution,
|
||||
prevLedger.getCloseAgree(), mLedgerSeq);
|
||||
if (prevLedger.mCloseTime == 0)
|
||||
{
|
||||
mCloseTime = theApp->getOPs().getCloseTimeNC() - mCloseResolution;
|
||||
mCloseTime -= (mCloseTime % mCloseResolution);
|
||||
}
|
||||
mCloseTime = roundCloseTime(theApp->getOPs().getCloseTimeNC(), mCloseResolution);
|
||||
else
|
||||
mCloseTime = prevLedger.mCloseTime + mCloseResolution;
|
||||
zeroFees();
|
||||
@@ -181,7 +178,7 @@ void Ledger::addRaw(Serializer &s) const
|
||||
void Ledger::setAccepted(uint32 closeTime, int closeResolution, bool correctCloseTime)
|
||||
{ // used when we witnessed the consensus
|
||||
assert(mClosed && !mAccepted);
|
||||
mCloseTime = correctCloseTime ? (closeTime - (closeTime % closeResolution)) : closeTime;
|
||||
mCloseTime = correctCloseTime ? roundCloseTime(closeTime, closeResolution) : closeTime;
|
||||
mCloseResolution = closeResolution;
|
||||
mCloseFlags = correctCloseTime ? 0 : sLCF_NoConsensusTime;
|
||||
mAccepted = true;
|
||||
@@ -192,7 +189,7 @@ void Ledger::setAccepted()
|
||||
{ // used when we acquired the ledger
|
||||
// FIXME assert(mClosed && (mCloseTime != 0) && (mCloseResolution != 0));
|
||||
if ((mCloseFlags & sLCF_NoConsensusTime) == 0)
|
||||
mCloseTime -= mCloseTime % mCloseResolution;
|
||||
mCloseTime = roundCloseTime(mCloseTime, mCloseResolution);
|
||||
mAccepted = true;
|
||||
setImmutable();
|
||||
}
|
||||
@@ -1422,6 +1419,13 @@ int Ledger::getPendingSaves()
|
||||
return sPendingSaves;
|
||||
}
|
||||
|
||||
uint32 Ledger::roundCloseTime(uint32 closeTime, uint32 closeResolution)
|
||||
{
|
||||
if (closeTime == 0)
|
||||
return 0;
|
||||
return closeTime - (closeTime % closeResolution);
|
||||
}
|
||||
|
||||
void Ledger::pendSave(bool fromConsensus)
|
||||
{
|
||||
if (!fromConsensus && !theApp->isNewFlag(getHash(), SF_SAVED))
|
||||
|
||||
@@ -123,6 +123,7 @@ public:
|
||||
static void getSQL2(Ledger::ref);
|
||||
static Ledger::pointer getLastFullLedger();
|
||||
static int getPendingSaves();
|
||||
static uint32 roundCloseTime(uint32 closeTime, uint32 closeResolution);
|
||||
|
||||
void updateHash();
|
||||
void setClosed() { mClosed = true; }
|
||||
|
||||
@@ -717,9 +717,8 @@ void LedgerConsensus::updateOurPositions()
|
||||
|
||||
// Verify freshness of peer positions and compute close times
|
||||
std::map<uint32, int> closeTimes;
|
||||
boost::unordered_map<uint160, LedgerProposal::pointer>::iterator
|
||||
it = mPeerPositions.begin(), end = mPeerPositions.end();
|
||||
while (it != end)
|
||||
boost::unordered_map<uint160, LedgerProposal::pointer>::iterator it = mPeerPositions.begin();
|
||||
while (it != mPeerPositions.end())
|
||||
{
|
||||
if (it->second->isStale(peerCutoff))
|
||||
{ // proposal is stale
|
||||
@@ -765,7 +764,8 @@ void LedgerConsensus::updateOurPositions()
|
||||
neededWeight = AV_INIT_CONSENSUS_PCT;
|
||||
else if (mClosePercent < AV_LATE_CONSENSUS_TIME)
|
||||
neededWeight = AV_MID_CONSENSUS_PCT;
|
||||
else neededWeight = AV_LATE_CONSENSUS_PCT;
|
||||
else
|
||||
neededWeight = AV_LATE_CONSENSUS_PCT;
|
||||
|
||||
uint32 closeTime = 0;
|
||||
mHaveCloseTimeConsensus = false;
|
||||
@@ -802,9 +802,9 @@ void LedgerConsensus::updateOurPositions()
|
||||
<< " Proposing:" << (mProposing ? "yes" : "no") << " Thresh:" << thresh << " Pos:" << closeTime;
|
||||
}
|
||||
|
||||
if ((!changes) &&
|
||||
((closeTime != (roundCloseTime(mOurPosition->getCloseTime()))) ||
|
||||
(mOurPosition->isStale(ourCutoff))))
|
||||
if (!changes &&
|
||||
((closeTime != roundCloseTime(mOurPosition->getCloseTime())) ||
|
||||
mOurPosition->isStale(ourCutoff)))
|
||||
{ // close time changed or our position is stale
|
||||
ourPosition = mAcquired[mOurPosition->getCurrentHash()]->snapShot(true);
|
||||
assert(ourPosition);
|
||||
@@ -835,7 +835,10 @@ bool LedgerConsensus::haveConsensus(bool forReal)
|
||||
if (it.second->getCurrentHash() == ourPosition)
|
||||
++agree;
|
||||
else
|
||||
{
|
||||
cLog(lsDEBUG) << it.first.GetHex() << " has " << it.second->getCurrentHash().GetHex();
|
||||
++disagree;
|
||||
}
|
||||
}
|
||||
}
|
||||
int currentValidations = theApp->getValidations().getNodesAfter(mPrevLedgerHash);
|
||||
@@ -849,38 +852,36 @@ bool LedgerConsensus::haveConsensus(bool forReal)
|
||||
SHAMap::pointer LedgerConsensus::getTransactionTree(const uint256& hash, bool doAcquire)
|
||||
{
|
||||
boost::unordered_map<uint256, SHAMap::pointer>::iterator it = mAcquired.find(hash);
|
||||
if (it == mAcquired.end())
|
||||
{ // we have not completed acquiring this ledger
|
||||
if (it != mAcquired.end())
|
||||
return it->second;
|
||||
|
||||
if (mState == lcsPRE_CLOSE)
|
||||
if (mState == lcsPRE_CLOSE)
|
||||
{
|
||||
SHAMap::pointer currentMap = theApp->getLedgerMaster().getCurrentLedger()->peekTransactionMap();
|
||||
if (currentMap->getHash() == hash)
|
||||
{
|
||||
SHAMap::pointer currentMap = theApp->getLedgerMaster().getCurrentLedger()->peekTransactionMap();
|
||||
if (currentMap->getHash() == hash)
|
||||
{
|
||||
currentMap = currentMap->snapShot(false);
|
||||
mapComplete(hash, currentMap, false);
|
||||
return currentMap;
|
||||
}
|
||||
currentMap = currentMap->snapShot(false);
|
||||
mapComplete(hash, currentMap, false);
|
||||
return currentMap;
|
||||
}
|
||||
|
||||
if (doAcquire)
|
||||
{
|
||||
TransactionAcquire::pointer& acquiring = mAcquiring[hash];
|
||||
if (!acquiring)
|
||||
{
|
||||
if (!hash)
|
||||
{
|
||||
SHAMap::pointer empty = boost::make_shared<SHAMap>(smtTRANSACTION);
|
||||
mapComplete(hash, empty, false);
|
||||
return empty;
|
||||
}
|
||||
acquiring = boost::make_shared<TransactionAcquire>(hash);
|
||||
startAcquiring(acquiring);
|
||||
}
|
||||
}
|
||||
return SHAMap::pointer();
|
||||
}
|
||||
return it->second;
|
||||
|
||||
if (doAcquire)
|
||||
{
|
||||
TransactionAcquire::pointer& acquiring = mAcquiring[hash];
|
||||
if (!acquiring)
|
||||
{
|
||||
if (!hash)
|
||||
{
|
||||
SHAMap::pointer empty = boost::make_shared<SHAMap>(smtTRANSACTION);
|
||||
mapComplete(hash, empty, false);
|
||||
return empty;
|
||||
}
|
||||
acquiring = boost::make_shared<TransactionAcquire>(hash);
|
||||
startAcquiring(acquiring);
|
||||
}
|
||||
}
|
||||
return SHAMap::pointer();
|
||||
}
|
||||
|
||||
void LedgerConsensus::startAcquiring(const TransactionAcquire::pointer& acquire)
|
||||
@@ -936,9 +937,8 @@ void LedgerConsensus::propose()
|
||||
|
||||
void LedgerConsensus::addDisputedTransaction(const uint256& txID, const std::vector<unsigned char>& tx)
|
||||
{
|
||||
if (mDisputes.find(txID) != mDisputes.end()) // Do we already have this entry?
|
||||
if (mDisputes.find(txID) != mDisputes.end())
|
||||
return;
|
||||
|
||||
cLog(lsDEBUG) << "Transaction " << txID << " is disputed";
|
||||
|
||||
bool ourVote = false;
|
||||
@@ -950,7 +950,6 @@ void LedgerConsensus::addDisputedTransaction(const uint256& txID, const std::vec
|
||||
else
|
||||
assert(false); // We don't have our own position?
|
||||
}
|
||||
cLog(lsDEBUG) << "Transaction " << txID << " is disputed";
|
||||
|
||||
LCTransaction::pointer txn = boost::make_shared<LCTransaction>(txID, tx, ourVote);
|
||||
mDisputes[txID] = txn;
|
||||
@@ -1120,7 +1119,6 @@ void LedgerConsensus::playbackProposals()
|
||||
theApp->getConnectionPool().relayMessageBut(peers, message);
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1249,7 +1247,7 @@ void LedgerConsensus::applyTransactions(SHAMap::ref set, Ledger::ref applyLedger
|
||||
|
||||
uint32 LedgerConsensus::roundCloseTime(uint32 closeTime)
|
||||
{
|
||||
return closeTime - (closeTime % mCloseResolution);
|
||||
return Ledger::roundCloseTime(closeTime, mCloseResolution);
|
||||
}
|
||||
|
||||
void LedgerConsensus::accept(SHAMap::ref set, LoadEvent::pointer)
|
||||
|
||||
@@ -845,7 +845,7 @@ void Peer::recvTransaction(ripple::TMTransaction& packet)
|
||||
|
||||
static void checkPropose(Job& job, boost::shared_ptr<ripple::TMProposeSet> packet,
|
||||
LedgerProposal::pointer proposal, uint256 consensusLCL, RippleAddress nodePublic, boost::weak_ptr<Peer> peer)
|
||||
{
|
||||
{ // Called from our JobQueue
|
||||
bool sigGood = false;
|
||||
bool isTrusted = (job.getType() == jtPROPOSAL_t);
|
||||
|
||||
@@ -877,7 +877,7 @@ static void checkPropose(Job& job, boost::shared_ptr<ripple::TMProposeSet> packe
|
||||
}
|
||||
else
|
||||
{
|
||||
cLog(lsWARNING) << "Ledger proposal fails signature check";
|
||||
cLog(lsWARNING) << "Ledger proposal fails signature check"; // Could be mismatched prev ledger
|
||||
proposal->setSignature(set.signature());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user