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

This commit is contained in:
Arthur Britto
2012-10-20 17:08:23 -07:00
10 changed files with 64 additions and 33 deletions

View File

@@ -108,6 +108,7 @@
<ClCompile Include="src\ECIES.cpp" />
<ClCompile Include="src\FieldNames.cpp" />
<ClCompile Include="src\HashedObject.cpp" />
<ClCompile Include="src\HTTPRequest.cpp" />
<ClCompile Include="src\HttpsClient.cpp" />
<ClCompile Include="src\Interpreter.cpp" />
<ClCompile Include="src\Ledger.cpp" />
@@ -134,7 +135,6 @@
<ClCompile Include="src\PeerDoor.cpp" />
<ClCompile Include="src\PlatRand.cpp" />
<ClCompile Include="src\PubKeyCache.cpp" />
<ClCompile Include="src\RequestParser.cpp" />
<ClCompile Include="src\rfc1751.cpp" />
<ClCompile Include="src\RippleCalc.cpp" />
<ClCompile Include="src\RippleLines.cpp" />

View File

@@ -120,9 +120,6 @@
<ClCompile Include="src\PubKeyCache.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="src\RequestParser.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="src\rfc1751.cpp">
<Filter>Source Files</Filter>
</ClCompile>
@@ -303,6 +300,9 @@
<ClCompile Include="obj\src\ripple.pb.cc">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="src\HTTPRequest.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="KnownNodeList.h">

View File

@@ -58,4 +58,4 @@ public:
int getDataSize() { return iDataSize; }
};
#endif
#endif

View File

@@ -318,7 +318,7 @@ bool LedgerEntrySet::threadTx(SLE::ref threadTo, Ledger::ref ledger,
uint32 prevLgrID;
if (!threadTo->thread(mSet.getTxID(), mSet.getLgrSeq(), prevTxID, prevLgrID))
return false;
if (TransactionMetaSet::thread(mSet.getAffectedNode(threadTo->getIndex(), sfModifiedNode, false),
if (TransactionMetaSet::thread(mSet.getAffectedNode(threadTo->getIndex(), sfModifiedNode),
prevTxID, prevLgrID))
return true;
assert(false);
@@ -395,7 +395,7 @@ void LedgerEntrySet::calcRawMeta(Serializer& s, TER result)
continue;
SLE::pointer curNode = it->second.mEntry;
STObject &metaNode = mSet.getAffectedNode(it->first, *type, true);
mSet.setAffectedNode(it->first, *type);
if (type == &sfDeletedNode)
{
@@ -406,16 +406,16 @@ void LedgerEntrySet::calcRawMeta(Serializer& s, TER result)
{ // node has an amount, covers ripple state nodes
STAmount amount = origNode->getFieldAmount(sfAmount);
if (amount.isNonZero())
metaNode.setFieldAmount(sfPreviousBalance, amount);
mSet.getAffectedNode(it->first).setFieldAmount(sfPreviousBalance, amount);
amount = curNode->getFieldAmount(sfAmount);
if (amount.isNonZero())
metaNode.setFieldAmount(sfFinalBalance, amount);
mSet.getAffectedNode(it->first).setFieldAmount(sfFinalBalance, amount);
if (origNode->getType() == ltRIPPLE_STATE)
{
metaNode.setFieldAccount(sfLowID,
mSet.getAffectedNode(it->first).setFieldAccount(sfLowID,
NewcoinAddress::createAccountID(origNode->getFieldAmount(sfLowLimit).getIssuer()));
metaNode.setFieldAccount(sfHighID,
mSet.getAffectedNode(it->first).setFieldAccount(sfHighID,
NewcoinAddress::createAccountID(origNode->getFieldAmount(sfHighLimit).getIssuer()));
}
}
@@ -424,10 +424,10 @@ void LedgerEntrySet::calcRawMeta(Serializer& s, TER result)
{ // check for non-zero balances
STAmount amount = origNode->getFieldAmount(sfTakerPays);
if (amount.isNonZero())
metaNode.setFieldAmount(sfFinalTakerPays, amount);
mSet.getAffectedNode(it->first).setFieldAmount(sfFinalTakerPays, amount);
amount = origNode->getFieldAmount(sfTakerGets);
if (amount.isNonZero())
metaNode.setFieldAmount(sfFinalTakerGets, amount);
mSet.getAffectedNode(it->first).setFieldAmount(sfFinalTakerGets, amount);
}
}
@@ -451,17 +451,17 @@ void LedgerEntrySet::calcRawMeta(Serializer& s, TER result)
{ // node has an amount, covers account root nodes and ripple nodes
STAmount amount = origNode->getFieldAmount(sfAmount);
if (amount != curNode->getFieldAmount(sfAmount))
metaNode.setFieldAmount(sfPreviousBalance, amount);
mSet.getAffectedNode(it->first).setFieldAmount(sfPreviousBalance, amount);
}
if (origNode->getType() == ltOFFER)
{
STAmount amount = origNode->getFieldAmount(sfTakerPays);
if (amount != curNode->getFieldAmount(sfTakerPays))
metaNode.setFieldAmount(sfPreviousTakerPays, amount);
mSet.getAffectedNode(it->first).setFieldAmount(sfPreviousTakerPays, amount);
amount = origNode->getFieldAmount(sfTakerGets);
if (amount != curNode->getFieldAmount(sfTakerGets))
metaNode.setFieldAmount(sfPreviousTakerGets, amount);
mSet.getAffectedNode(it->first).setFieldAmount(sfPreviousTakerGets, amount);
}
}

View File

@@ -2518,7 +2518,7 @@ Json::Value RPCServer::doWalletPropose(const Json::Value& params)
Json::Value obj(Json::objectValue);
obj["master_seed"] = naSeed.humanSeed();
obj["master_key"] = naSeed.humanSeed1751();
//obj["master_key"] = naSeed.humanSeed1751();
obj["account_id"] = naAccount.humanAccountID();
return obj;

View File

@@ -12,11 +12,12 @@ RippleLines::RippleLines(const uint160& accountID, Ledger::pointer ledger)
fillLines(accountID,ledger);
}
void RippleLines::printRippleLines() {
for (int i =0; i < mLines.size(); i++) {
std::cout << i << ": " << mLines[i]->getAccountID().humanAccountID() << std::endl;
}
std::cout << std::endl;
void RippleLines::printRippleLines()
{
for (unsigned int i =0; i < mLines.size(); i++) {
std::cout << i << ": " << mLines[i]->getAccountID().humanAccountID() << std::endl;
}
std::cout << std::endl;
}
RippleLines::RippleLines(const uint160& accountID )

View File

@@ -170,7 +170,9 @@ protected:
public:
STArray() { ; }
STArray(int n) { value.reserve(n); }
STArray(SField::ref f) : SerializedType(f) { ; }
STArray(SField::ref f, int n) : SerializedType(f) { value.reserve(n); }
STArray(SField::ref f, const vector& v) : SerializedType(f), value(v) { ; }
STArray(vector& v) : value(v) { ; }

View File

@@ -36,13 +36,11 @@ protected:
SField::ptr fName;
virtual SerializedType* duplicate() const { return new SerializedType(*fName); }
SerializedType(SField::ptr n) : fName(n) { assert(fName); }
public:
SerializedType() : fName(&sfGeneric) { ; }
SerializedType(SField::ref n) : fName(&n) { assert(fName); }
SerializedType(const SerializedType& n) : fName(n.fName) { ; }
virtual ~SerializedType() { ; }
static std::auto_ptr<SerializedType> deserialize(SField::ref name)

View File

@@ -6,8 +6,10 @@
#include <boost/bind.hpp>
#include <boost/foreach.hpp>
#include "Log.h"
TransactionMetaSet::TransactionMetaSet(const uint256& txid, uint32 ledger, const std::vector<unsigned char>& vec) :
mTransactionID(txid), mLedger(ledger), mNodes(sfAffectedNodes)
mTransactionID(txid), mLedger(ledger), mNodes(sfAffectedNodes, 32)
{
Serializer s(vec);
SerializerIterator sit(s);
@@ -29,15 +31,14 @@ bool TransactionMetaSet::isNodeAffected(const uint256& node) const
return false;
}
STObject& TransactionMetaSet::getAffectedNode(const uint256& node, SField::ref type, bool overrideType)
{
void TransactionMetaSet::setAffectedNode(const uint256& node, SField::ref type)
{ // make sure the node exists and force its type
for (STArray::iterator it = mNodes.begin(); it != mNodes.end(); ++it)
{
if (it->getFieldH256(sfLedgerIndex) == node)
{
if (overrideType)
it->setFName(type);
return *it;
it->setFName(type);
return;
}
}
@@ -46,8 +47,35 @@ STObject& TransactionMetaSet::getAffectedNode(const uint256& node, SField::ref t
assert(obj.getFName() == type);
obj.setFieldH256(sfLedgerIndex, node);
}
return mNodes.back();
STObject& TransactionMetaSet::getAffectedNode(const uint256& node, SField::ref type)
{
assert(&type);
for (STArray::iterator it = mNodes.begin(); it != mNodes.end(); ++it)
{
if (it->getFieldH256(sfLedgerIndex) == node)
return *it;
}
mNodes.push_back(STObject(sfModifiedNode));
STObject& obj = mNodes.back();
assert(obj.getFName() == type);
obj.setFieldH256(sfLedgerIndex, node);
return obj;
}
STObject& TransactionMetaSet::getAffectedNode(const uint256& node)
{
for (STArray::iterator it = mNodes.begin(); it != mNodes.end(); ++it)
{
if (it->getFieldH256(sfLedgerIndex) == node)
return *it;
}
assert(false);
throw std::runtime_error("Affected node not found");
}
const STObject& TransactionMetaSet::peekAffectedNode(const uint256& node) const
@@ -62,7 +90,7 @@ void TransactionMetaSet::init(const uint256& id, uint32 ledger)
{
mTransactionID = id;
mLedger = ledger;
mNodes = STArray(sfAffectedNodes);
mNodes = STArray(sfAffectedNodes, 32);
}
void TransactionMetaSet::swap(TransactionMetaSet& s)

View File

@@ -39,7 +39,9 @@ public:
uint32 getLgrSeq() { return mLedger; }
bool isNodeAffected(const uint256&) const;
STObject& getAffectedNode(const uint256&, SField::ref type, bool overrideType);
void setAffectedNode(const uint256&, SField::ref type);
STObject& getAffectedNode(const uint256&, SField::ref type);
STObject& getAffectedNode(const uint256&);
const STObject& peekAffectedNode(const uint256&) const;
Json::Value getJson(int p) const { return getAsObject().getJson(p); }