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

This commit is contained in:
Arthur Britto
2013-02-27 18:44:06 -08:00
8 changed files with 55 additions and 33 deletions

View File

@@ -451,9 +451,11 @@ void Ledger::saveAcceptedLedger(bool fromConsensus, LoadEvent::pointer event)
std::string escMeta(sqlEscape(rawMeta.peekData()));
SerializerIterator txnIt(rawTxn);
SerializedTransaction txn(txnIt);
assert(txn.getTransactionID() == item->getTag());
TransactionMetaSet meta(item->getTag(), mLedgerSeq, rawMeta.peekData());
theApp->getMasterTransaction().inLedger(item->getTag(), mLedgerSeq);
// Make sure transaction is in AccountTransactions.
if (!SQL_EXISTS(db, boost::str(AcctTransExists % item->getTag().GetHex())))

View File

@@ -1025,7 +1025,7 @@ uint32 LedgerEntrySet::rippleQualityIn(const uint160& uToAccountID, const uint16
}
}
cLog(lsINFO) << boost::str(boost::format("rippleQuality: %s uToAccountID=%s uFromAccountID=%s uCurrencyID=%s bLine=%d uQuality=%f")
cLog(lsTRACE) << boost::str(boost::format("rippleQuality: %s uToAccountID=%s uFromAccountID=%s uCurrencyID=%s bLine=%d uQuality=%f")
% (sfLow == sfLowQualityIn ? "in" : "out")
% RippleAddress::createHumanAccountID(uToAccountID)
% RippleAddress::createHumanAccountID(uFromAccountID)

View File

@@ -72,7 +72,7 @@ TER PathState::pushImply(
const PaymentNode& pnPrv = vpnNodes.back();
TER terResult = tesSUCCESS;
cLog(lsINFO) << "pushImply> "
cLog(lsTRACE) << "pushImply> "
<< RippleAddress::createHumanAccountID(uAccountID)
<< " " << STAmount::createHumanCurrency(uCurrencyID)
<< " " << RippleAddress::createHumanAccountID(uIssuerID);
@@ -107,7 +107,7 @@ TER PathState::pushImply(
uIssuerID);
}
cLog(lsINFO) << boost::str(boost::format("pushImply< : %s") % transToken(terResult));
cLog(lsTRACE) << boost::str(boost::format("pushImply< : %s") % transToken(terResult));
return terResult;
}
@@ -133,7 +133,7 @@ TER PathState::pushNode(
const bool bIssuer = isSetBit(iType, STPathElement::typeIssuer);
TER terResult = tesSUCCESS;
cLog(lsDEBUG) << "pushNode> "
cLog(lsTRACE) << "pushNode> "
<< iType
<< ": " << (bAccount ? RippleAddress::createHumanAccountID(uAccountID) : "-")
<< " " << (bCurrency ? STAmount::createHumanCurrency(uCurrencyID) : "-")
@@ -209,7 +209,7 @@ TER PathState::pushNode(
if (!sleRippleState)
{
cLog(lsINFO) << "pushNode: No credit line between "
cLog(lsTRACE) << "pushNode: No credit line between "
<< RippleAddress::createHumanAccountID(pnBck.uAccountID)
<< " and "
<< RippleAddress::createHumanAccountID(pnCur.uAccountID)
@@ -217,13 +217,13 @@ TER PathState::pushNode(
<< STAmount::createHumanCurrency(pnCur.uCurrencyID)
<< "." ;
cLog(lsINFO) << getJson();
cLog(lsTRACE) << getJson();
terResult = terNO_LINE;
}
else
{
cLog(lsINFO) << "pushNode: Credit line found between "
cLog(lsDEBUG) << "pushNode: Credit line found between "
<< RippleAddress::createHumanAccountID(pnBck.uAccountID)
<< " and "
<< RippleAddress::createHumanAccountID(pnCur.uAccountID)
@@ -280,7 +280,7 @@ TER PathState::pushNode(
vpnNodes.push_back(pnCur);
}
}
cLog(lsINFO) << boost::str(boost::format("pushNode< : %s") % transToken(terResult));
cLog(lsDEBUG) << boost::str(boost::format("pushNode< : %s") % transToken(terResult));
return terResult;
}
@@ -1660,7 +1660,7 @@ TER RippleCalc::calcNodeAccountRev(const unsigned int uNode, PathState& psCur, c
? lesActive.rippleOwed(uCurAccountID, uNxtAccountID, uCurrencyID)
: STAmount(uCurrencyID, uCurAccountID);
cLog(lsDEBUG) << boost::str(boost::format("calcNodeAccountRev> uNode=%d/%d uPrvAccountID=%s uCurAccountID=%s uNxtAccountID=%s uCurrencyID=%s uQualityIn=%d uQualityOut=%d saPrvOwed=%s saPrvLimit=%s")
cLog(lsTRACE) << boost::str(boost::format("calcNodeAccountRev> uNode=%d/%d uPrvAccountID=%s uCurAccountID=%s uNxtAccountID=%s uCurrencyID=%s uQualityIn=%d uQualityOut=%d saPrvOwed=%s saPrvLimit=%s")
% uNode
% uLast
% RippleAddress::createHumanAccountID(uPrvAccountID)
@@ -1695,14 +1695,14 @@ TER RippleCalc::calcNodeAccountRev(const unsigned int uNode, PathState& psCur, c
const STAmount& saCurDeliverReq = pnCur.saRevDeliver;
STAmount saCurDeliverAct(saCurDeliverReq.getCurrency(), saCurDeliverReq.getIssuer());
cLog(lsDEBUG) << boost::str(boost::format("calcNodeAccountRev: saPrvRedeemReq=%s saPrvIssueReq=%s saCurRedeemReq=%s saCurIssueReq=%s saNxtOwed=%s")
cLog(lsTRACE) << boost::str(boost::format("calcNodeAccountRev: saPrvRedeemReq=%s saPrvIssueReq=%s saCurRedeemReq=%s saCurIssueReq=%s saNxtOwed=%s")
% saPrvRedeemReq.getFullText()
% saPrvIssueReq.getFullText()
% saCurRedeemReq.getFullText()
% saCurIssueReq.getFullText()
% saNxtOwed.getFullText());
cLog(lsDEBUG) << psCur.getJson();
cLog(lsTRACE) << psCur.getJson();
assert(!saCurRedeemReq || (-saNxtOwed) >= saCurRedeemReq); // Current redeem req can't be more than IOUs on hand.
assert(!saCurIssueReq // If not issuing, fine.

View File

@@ -11,24 +11,32 @@ AccountItem::pointer RippleState::makeItem(const uint160& accountID, SerializedL
}
RippleState::RippleState(SerializedLedgerEntry::ref ledgerEntry) : AccountItem(ledgerEntry),
mValid(false),
mViewLowest(true)
mValid(false), mViewLowest(true)
{
mFlags = mLedgerEntry->getFieldU32(sfFlags);
mLowLimit = mLedgerEntry->getFieldAmount(sfLowLimit);
mHighLimit = mLedgerEntry->getFieldAmount(sfHighLimit);
for (int i = 0, iMax = mLedgerEntry->getCount(); i < iMax; ++i)
{
const SerializedType* entry = mLedgerEntry->peekAtPIndex(i);
assert(entry);
if (entry->getFName() == sfFlags)
mFlags = static_cast<const STUInt32*>(entry)->getValue();
else if (entry->getFName() == sfLowLimit)
{
mLowLimit = *static_cast<const STAmount*>(entry);
mLowID = RippleAddress::createAccountID(mLowLimit.getIssuer());
}
else if (entry->getFName() == sfHighLimit)
{
mHighLimit = *static_cast<const STAmount*>(entry);
mHighID = RippleAddress::createAccountID(mHighLimit.getIssuer());
mLowQualityIn = mLedgerEntry->getFieldU32(sfLowQualityIn);
mLowQualityOut = mLedgerEntry->getFieldU32(sfLowQualityOut);
mHighQualityIn = mLedgerEntry->getFieldU32(sfHighQualityIn);
mHighQualityOut = mLedgerEntry->getFieldU32(sfHighQualityOut);
mBalance = mLedgerEntry->getFieldAmount(sfBalance);
}
else if (entry->getFName() == sfLowQualityIn)
mLowQualityIn = static_cast<const STUInt32*>(entry)->getValue();
else if (entry->getFName() == sfHighQualityIn)
mHighQualityIn = static_cast<const STUInt32*>(entry)->getValue();
else if (entry->getFName() == sfBalance)
mBalance = *static_cast<const STAmount*>(entry);
}
mValid = true;
}

View File

@@ -18,13 +18,24 @@ TransactionMaster::TransactionMaster() : mCache("TransactionCache", CACHED_TRANS
;
}
bool TransactionMaster::inLedger(const uint256& hash, uint32 ledger)
{
Transaction::pointer txn = mCache.fetch(hash);
if (!txn)
return false;
txn->setStatus(COMMITTED, ledger);
return true;
}
Transaction::pointer TransactionMaster::fetch(const uint256& txnID, bool checkDisk)
{
Transaction::pointer txn = mCache.fetch(txnID);
if (!checkDisk || txn) return txn;
if (!checkDisk || txn)
return txn;
txn = Transaction::load(txnID);
if (!txn) return txn;
if (!txn)
return txn;
mCache.canonicalize(txnID, txn);

View File

@@ -20,6 +20,7 @@ public:
bool checkDisk, uint32 uCommitLedger);
// return value: true = we had the transaction already
bool inLedger(const uint256& hash, uint32 ledger);
bool canonicalize(Transaction::pointer& txn, bool maybeNew);
void sweep(void) { mCache.sweep(); }
};

View File

@@ -293,11 +293,10 @@ void ValidationCollection::condWrite()
if (mWriting)
return;
mWriting = true;
boost::thread thread(boost::bind(&ValidationCollection::doWrite, this));
thread.detach();
theApp->getJobQueue().addJob(jtWRITE, boost::bind(&ValidationCollection::doWrite, this, _1));
}
void ValidationCollection::doWrite()
void ValidationCollection::doWrite(Job&)
{
LoadEvent::autoptr event(theApp->getJobQueue().getLoadEventAP(jtDISK));
static boost::format insVal("INSERT INTO Validations "

View File

@@ -10,6 +10,7 @@
#include "types.h"
#include "SerializedValidation.h"
#include "TaggedCache.h"
#include "JobQueue.h"
typedef boost::unordered_map<uint160, SerializedValidation::pointer> ValidationSet;
@@ -26,7 +27,7 @@ protected:
bool mWriting;
void doWrite();
void doWrite(Job&);
void condWrite();
boost::shared_ptr<ValidationSet> findCreateSet(const uint256& ledgerHash);