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

This commit is contained in:
Arthur Britto
2012-07-17 16:20:32 -07:00
5 changed files with 29 additions and 29 deletions

View File

@@ -230,11 +230,6 @@ bool Ledger::addTransaction(const uint256& txID, const Serializer& txn)
return true;
}
bool Ledger::hasTransaction(const uint256& transID) const
{
return mTransactionMap->hasItem(transID);
}
Transaction::pointer Ledger::getTransaction(const uint256& transID) const
{
SHAMapItem::pointer item = mTransactionMap->peekItem(transID);

View File

@@ -151,7 +151,7 @@ public:
bool isAcquiringAS(void);
// Transaction Functions
bool hasTransaction(const uint256& TransID) const;
bool hasTransaction(const uint256& TransID) const { return mTransactionMap->hasItem(TransID); }
Transaction::pointer getTransaction(const uint256& transID) const;
// high-level functions

View File

@@ -735,29 +735,32 @@ void LedgerConsensus::applyTransaction(TransactionEngine& engine, SerializedTran
#endif
}
void LedgerConsensus::applyTransactions(SHAMap::pointer set, Ledger::pointer ledger,
void LedgerConsensus::applyTransactions(SHAMap::pointer set, Ledger::pointer applyLedger, Ledger::pointer checkLedger,
CanonicalTXSet& failedTransactions, bool final)
{
TransactionEngineParams parms = final ? (tepNO_CHECK_FEE | tepUPDATE_TOTAL) : tepNONE;
TransactionEngine engine(ledger);
TransactionEngine engine(applyLedger);
for (SHAMapItem::pointer item = set->peekFirstItem(); !!item; item = set->peekNextItem(item->getTag()))
{
Log(lsINFO) << "Processing candidate transaction: " << item->getTag().GetHex();
#ifndef TRUST_NETWORK
try
if (!checkLedger->hasTransaction(item->getTag()))
{
#endif
SerializerIterator sit(item->peekSerializer());
SerializedTransaction::pointer txn = boost::make_shared<SerializedTransaction>(boost::ref(sit));
applyTransaction(engine, txn, ledger, failedTransactions, final);
Log(lsINFO) << "Processing candidate transaction: " << item->getTag().GetHex();
#ifndef TRUST_NETWORK
}
catch (...)
{
Log(lsWARNING) << " Throws";
}
try
{
#endif
SerializerIterator sit(item->peekSerializer());
SerializedTransaction::pointer txn = boost::make_shared<SerializedTransaction>(boost::ref(sit));
applyTransaction(engine, txn, applyLedger, failedTransactions, final);
#ifndef TRUST_NETWORK
}
catch (...)
{
Log(lsWARNING) << " Throws";
}
#endif
}
}
int successes;
@@ -800,7 +803,7 @@ void LedgerConsensus::accept(SHAMap::pointer set)
newLCL->armDirty();
CanonicalTXSet failedTransactions(set->getHash());
applyTransactions(set, newLCL, failedTransactions, true);
applyTransactions(set, newLCL, newLCL, failedTransactions, true);
newLCL->setClosed();
uint32 closeTime = mOurPosition->getCloseTime();
@@ -843,6 +846,7 @@ void LedgerConsensus::accept(SHAMap::pointer set)
{ // we voted NO
try
{
Log(lsINFO) << "Test applying disputed transaction that did not get in";
SerializerIterator sit(it->second->peekTransaction());
SerializedTransaction::pointer txn = boost::make_shared<SerializedTransaction>(boost::ref(sit));
applyTransaction(engine, txn, newOL, failedTransactions, false);
@@ -854,7 +858,8 @@ void LedgerConsensus::accept(SHAMap::pointer set)
}
}
applyTransactions(theApp->getMasterLedger().getCurrentLedger()->peekTransactionMap(), newOL,
Log(lsINFO) << "Applying transactions from current ledger";
applyTransactions(theApp->getMasterLedger().getCurrentLedger()->peekTransactionMap(), newOL, newLCL,
failedTransactions, false);
theApp->getMasterLedger().pushLedger(newLCL, newOL);
mNewLedgerHash = newLCL->getHash();

View File

@@ -125,7 +125,7 @@ protected:
void addPosition(LedgerProposal&, bool ours);
void removePosition(LedgerProposal&, bool ours);
void sendHaveTxSet(const uint256& set, bool direct);
void applyTransactions(SHAMap::pointer transactionSet, Ledger::pointer targetLedger,
void applyTransactions(SHAMap::pointer transactionSet, Ledger::pointer targetLedger, Ledger::pointer checkLedger,
CanonicalTXSet& failedTransactions, bool final);
void applyTransaction(TransactionEngine& engine, SerializedTransaction::pointer txn, Ledger::pointer targetLedger,
CanonicalTXSet& failedTransactions, bool final);

View File

@@ -170,7 +170,7 @@ SHAMapTreeNode* SHAMap::walkToPointer(const uint256& id)
{
int branch = inNode->selectBranch(id);
const uint256& nextHash = inNode->getChildHash(branch);
if (!nextHash) return NULL;
if (nextHash.isZero()) return NULL;
inNode = getNodePointer(inNode->getChildNodeID(branch), nextHash);
if (!inNode)
throw SHAMapMissingNode(inNode->getChildNodeID(branch), nextHash);
@@ -437,7 +437,7 @@ bool SHAMap::delItem(const uint256& id)
SHAMapTreeNode::pointer leaf=stack.top();
stack.pop();
if( !leaf || !leaf->hasItem() || (leaf->peekItem()->getTag()!=id) )
if (!leaf || !leaf->hasItem() || (leaf->peekItem()->getTag() != id))
return false;
SHAMapTreeNode::TNType type=leaf->getType();
@@ -446,19 +446,19 @@ bool SHAMap::delItem(const uint256& id)
assert(false);
uint256 prevHash;
while(!stack.empty())
while (!stack.empty())
{
SHAMapTreeNode::pointer node=stack.top();
stack.pop();
returnNode(node, true);
assert(node->isInner());
if(!node->setChildHash(node->selectBranch(id), prevHash))
if (!node->setChildHash(node->selectBranch(id), prevHash))
{
assert(false);
return true;
}
if(!node->isRoot())
if (!node->isRoot())
{ // we may have made this a node with 1 or 0 children
int bc=node->getBranchCount();
if(bc==0)
@@ -467,7 +467,7 @@ bool SHAMap::delItem(const uint256& id)
std::cerr << "delItem makes empty node" << std::endl;
#endif
prevHash=uint256();
if(!mTNByID.erase(*node))
if (!mTNByID.erase(*node))
assert(false);
}
else if(bc==1)