mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 17:27:55 +00:00
Merge branch 'master' of github.com:jedmccaleb/NewCoin
This commit is contained in:
@@ -378,7 +378,7 @@ bool STAmount::setFullValue(const std::string& sAmount, const std::string& sCurr
|
||||
|
||||
void STAmount::canonicalize()
|
||||
{
|
||||
if (!mCurrency)
|
||||
if (mCurrency.isZero())
|
||||
{ // native currency amounts should always have an offset of zero
|
||||
mIsNative = true;
|
||||
|
||||
@@ -401,7 +401,11 @@ void STAmount::canonicalize()
|
||||
--mOffset;
|
||||
}
|
||||
|
||||
assert(mValue <= cMaxNative);
|
||||
if (mValue > cMaxNative)
|
||||
{
|
||||
assert(false);
|
||||
throw std::runtime_error("Native currency amount out of range");
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -430,9 +434,9 @@ void STAmount::canonicalize()
|
||||
mValue /= 10;
|
||||
++mOffset;
|
||||
}
|
||||
assert((mValue == 0) || ((mValue >= cMinValue) && (mValue <= cMaxValue)) );
|
||||
assert((mValue == 0) || ((mOffset >= cMinOffset) && (mOffset <= cMaxOffset)) );
|
||||
assert((mValue != 0) || (mOffset != -100) );
|
||||
assert((mValue == 0) || ((mValue >= cMinValue) && (mValue <= cMaxValue)));
|
||||
assert((mValue == 0) || ((mOffset >= cMinOffset) && (mOffset <= cMaxOffset)));
|
||||
assert((mValue != 0) || (mOffset != -100));
|
||||
}
|
||||
|
||||
void STAmount::add(Serializer& s) const
|
||||
@@ -476,15 +480,24 @@ void STAmount::setValue(const STAmount &a)
|
||||
mIsNegative = a.mIsNegative;
|
||||
}
|
||||
|
||||
uint64 STAmount::toUInt64() const
|
||||
{ // makes them sort easily
|
||||
if (mIsNative)
|
||||
return mValue;
|
||||
if (mValue == 0)
|
||||
return 0x4000000000000000ull;
|
||||
if (mIsNegative)
|
||||
return ((cMaxNative + 1) - mValue) | (static_cast<uint64>(mOffset + 97) << (64 - 10));
|
||||
return mValue | (static_cast<uint64>(mOffset + 256 + 97) << (64 - 10));
|
||||
int STAmount::compare(const STAmount& a) const
|
||||
{ // Compares the value of a to the value of this STAmount, amounts must be comparable
|
||||
if (mIsNegative != a.mIsNegative) return mIsNegative ? -1 : 1;
|
||||
|
||||
if (!mValue)
|
||||
{
|
||||
if (a.mIsNegative) return 1;
|
||||
return a.mValue ? -1 : 0;
|
||||
}
|
||||
if (!a.mValue) return 1;
|
||||
|
||||
if (mOffset > a.mOffset) return mIsNegative ? -1 : 1;
|
||||
if (mOffset < a.mOffset) return mIsNegative ? 1 : -1;
|
||||
|
||||
if (mValue > a.mValue) return mIsNegative ? -1 : 1;
|
||||
if (mValue < a.mValue) return mIsNegative ? 1 : -1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
STAmount* STAmount::construct(SerializerIterator& sit, SField::ref name)
|
||||
@@ -633,25 +646,25 @@ bool STAmount::operator!=(const STAmount& a) const
|
||||
bool STAmount::operator<(const STAmount& a) const
|
||||
{
|
||||
throwComparable(a);
|
||||
return toUInt64() < a.toUInt64();
|
||||
return compare(a) < 0;
|
||||
}
|
||||
|
||||
bool STAmount::operator>(const STAmount& a) const
|
||||
{
|
||||
throwComparable(a);
|
||||
return toUInt64() > a.toUInt64();
|
||||
return compare(a) > 0;
|
||||
}
|
||||
|
||||
bool STAmount::operator<=(const STAmount& a) const
|
||||
{
|
||||
throwComparable(a);
|
||||
return toUInt64() <= a.toUInt64();
|
||||
return compare(a) <= 0;
|
||||
}
|
||||
|
||||
bool STAmount::operator>=(const STAmount& a) const
|
||||
{
|
||||
throwComparable(a);
|
||||
return toUInt64() >= a.toUInt64();
|
||||
return compare(a) >= 0;
|
||||
}
|
||||
|
||||
STAmount& STAmount::operator+=(const STAmount& a)
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
|
||||
#define TRUST_NETWORK
|
||||
|
||||
// #define LC_DEBUG
|
||||
#define LC_DEBUG
|
||||
|
||||
typedef std::pair<const uint160, LedgerProposal::pointer> u160_prop_pair;
|
||||
typedef std::pair<const uint256, LCTransaction::pointer> u256_lct_pair;
|
||||
|
||||
@@ -51,7 +51,7 @@ void LedgerEntrySet::swapWith(LedgerEntrySet& e)
|
||||
// This is basically: copy-on-read.
|
||||
SLE::pointer LedgerEntrySet::getEntry(const uint256& index, LedgerEntryAction& action)
|
||||
{
|
||||
boost::unordered_map<uint256, LedgerEntrySetEntry>::iterator it = mEntries.find(index);
|
||||
std::map<uint256, LedgerEntrySetEntry>::iterator it = mEntries.find(index);
|
||||
if (it == mEntries.end())
|
||||
{
|
||||
action = taaNONE;
|
||||
@@ -98,7 +98,7 @@ SLE::pointer LedgerEntrySet::entryCache(LedgerEntryType letType, const uint256&
|
||||
|
||||
LedgerEntryAction LedgerEntrySet::hasEntry(const uint256& index) const
|
||||
{
|
||||
boost::unordered_map<uint256, LedgerEntrySetEntry>::const_iterator it = mEntries.find(index);
|
||||
std::map<uint256, LedgerEntrySetEntry>::const_iterator it = mEntries.find(index);
|
||||
if (it == mEntries.end())
|
||||
return taaNONE;
|
||||
return it->second.mAction;
|
||||
@@ -106,7 +106,7 @@ LedgerEntryAction LedgerEntrySet::hasEntry(const uint256& index) const
|
||||
|
||||
void LedgerEntrySet::entryCache(SLE::ref sle)
|
||||
{
|
||||
boost::unordered_map<uint256, LedgerEntrySetEntry>::iterator it = mEntries.find(sle->getIndex());
|
||||
std::map<uint256, LedgerEntrySetEntry>::iterator it = mEntries.find(sle->getIndex());
|
||||
if (it == mEntries.end())
|
||||
{
|
||||
mEntries.insert(std::make_pair(sle->getIndex(), LedgerEntrySetEntry(sle, taaCACHED, mSeq)));
|
||||
@@ -127,7 +127,7 @@ void LedgerEntrySet::entryCache(SLE::ref sle)
|
||||
|
||||
void LedgerEntrySet::entryCreate(SLE::ref sle)
|
||||
{
|
||||
boost::unordered_map<uint256, LedgerEntrySetEntry>::iterator it = mEntries.find(sle->getIndex());
|
||||
std::map<uint256, LedgerEntrySetEntry>::iterator it = mEntries.find(sle->getIndex());
|
||||
if (it == mEntries.end())
|
||||
{
|
||||
mEntries.insert(std::make_pair(sle->getIndex(), LedgerEntrySetEntry(sle, taaCREATE, mSeq)));
|
||||
@@ -157,7 +157,7 @@ void LedgerEntrySet::entryCreate(SLE::ref sle)
|
||||
|
||||
void LedgerEntrySet::entryModify(SLE::ref sle)
|
||||
{
|
||||
boost::unordered_map<uint256, LedgerEntrySetEntry>::iterator it = mEntries.find(sle->getIndex());
|
||||
std::map<uint256, LedgerEntrySetEntry>::iterator it = mEntries.find(sle->getIndex());
|
||||
if (it == mEntries.end())
|
||||
{
|
||||
mEntries.insert(std::make_pair(sle->getIndex(), LedgerEntrySetEntry(sle, taaMODIFY, mSeq)));
|
||||
@@ -192,7 +192,7 @@ void LedgerEntrySet::entryModify(SLE::ref sle)
|
||||
|
||||
void LedgerEntrySet::entryDelete(SLE::ref sle)
|
||||
{
|
||||
boost::unordered_map<uint256, LedgerEntrySetEntry>::iterator it = mEntries.find(sle->getIndex());
|
||||
std::map<uint256, LedgerEntrySetEntry>::iterator it = mEntries.find(sle->getIndex());
|
||||
if (it == mEntries.end())
|
||||
{
|
||||
mEntries.insert(std::make_pair(sle->getIndex(), LedgerEntrySetEntry(sle, taaDELETE, mSeq)));
|
||||
@@ -233,7 +233,7 @@ Json::Value LedgerEntrySet::getJson(int) const
|
||||
Json::Value ret(Json::objectValue);
|
||||
|
||||
Json::Value nodes(Json::arrayValue);
|
||||
for (boost::unordered_map<uint256, LedgerEntrySetEntry>::const_iterator it = mEntries.begin(),
|
||||
for (std::map<uint256, LedgerEntrySetEntry>::const_iterator it = mEntries.begin(),
|
||||
end = mEntries.end(); it != end; ++it)
|
||||
{
|
||||
Json::Value entry(Json::objectValue);
|
||||
@@ -269,7 +269,7 @@ Json::Value LedgerEntrySet::getJson(int) const
|
||||
SLE::pointer LedgerEntrySet::getForMod(const uint256& node, Ledger::ref ledger,
|
||||
boost::unordered_map<uint256, SLE::pointer>& newMods)
|
||||
{
|
||||
boost::unordered_map<uint256, LedgerEntrySetEntry>::iterator it = mEntries.find(node);
|
||||
std::map<uint256, LedgerEntrySetEntry>::iterator it = mEntries.find(node);
|
||||
if (it != mEntries.end())
|
||||
{
|
||||
if (it->second.mAction == taaDELETE)
|
||||
@@ -351,7 +351,7 @@ void LedgerEntrySet::calcRawMeta(Serializer& s)
|
||||
// Entries modified only as a result of building the transaction metadata
|
||||
boost::unordered_map<uint256, SLE::pointer> newMod;
|
||||
|
||||
for (boost::unordered_map<uint256, LedgerEntrySetEntry>::const_iterator it = mEntries.begin(),
|
||||
for (std::map<uint256, LedgerEntrySetEntry>::const_iterator it = mEntries.begin(),
|
||||
end = mEntries.end(); it != end; ++it)
|
||||
{
|
||||
int nType = TMNEndOfMetadata;
|
||||
@@ -410,8 +410,10 @@ void LedgerEntrySet::calcRawMeta(Serializer& s)
|
||||
|
||||
if (origNode->getType() == ltRIPPLE_STATE)
|
||||
{
|
||||
metaNode.addAccount(TMSLowID, NewcoinAddress::createAccountID(origNode->getFieldAmount(sfLowLimit).getIssuer()));
|
||||
metaNode.addAccount(TMSHighID, NewcoinAddress::createAccountID(origNode->getFieldAmount(sfHighLimit).getIssuer()));
|
||||
metaNode.addAccount(TMSLowID,
|
||||
NewcoinAddress::createAccountID(origNode->getFieldAmount(sfLowLimit).getIssuer()));
|
||||
metaNode.addAccount(TMSHighID,
|
||||
NewcoinAddress::createAccountID(origNode->getFieldAmount(sfHighLimit).getIssuer()));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -32,11 +32,11 @@ class LedgerEntrySet
|
||||
{
|
||||
protected:
|
||||
Ledger::pointer mLedger;
|
||||
boost::unordered_map<uint256, LedgerEntrySetEntry> mEntries;
|
||||
std::map<uint256, LedgerEntrySetEntry> mEntries; // cannot be unordered!
|
||||
TransactionMetaSet mSet;
|
||||
int mSeq;
|
||||
|
||||
LedgerEntrySet(Ledger::ref ledger, const boost::unordered_map<uint256, LedgerEntrySetEntry> &e,
|
||||
LedgerEntrySet(Ledger::ref ledger, const std::map<uint256, LedgerEntrySetEntry> &e,
|
||||
const TransactionMetaSet& s, int m) : mLedger(ledger), mEntries(e), mSet(s), mSeq(m) { ; }
|
||||
|
||||
SLE::pointer getForMod(const uint256& node, Ledger::ref ledger,
|
||||
@@ -123,11 +123,11 @@ public:
|
||||
void calcRawMeta(Serializer&);
|
||||
|
||||
// iterator functions
|
||||
bool isEmpty() const { return mEntries.empty(); }
|
||||
boost::unordered_map<uint256, LedgerEntrySetEntry>::const_iterator begin() const { return mEntries.begin(); }
|
||||
boost::unordered_map<uint256, LedgerEntrySetEntry>::const_iterator end() const { return mEntries.end(); }
|
||||
boost::unordered_map<uint256, LedgerEntrySetEntry>::iterator begin() { return mEntries.begin(); }
|
||||
boost::unordered_map<uint256, LedgerEntrySetEntry>::iterator end() { return mEntries.end(); }
|
||||
bool isEmpty() const { return mEntries.empty(); }
|
||||
std::map<uint256, LedgerEntrySetEntry>::const_iterator begin() const { return mEntries.begin(); }
|
||||
std::map<uint256, LedgerEntrySetEntry>::const_iterator end() const { return mEntries.end(); }
|
||||
std::map<uint256, LedgerEntrySetEntry>::iterator begin() { return mEntries.begin(); }
|
||||
std::map<uint256, LedgerEntrySetEntry>::iterator end() { return mEntries.end(); }
|
||||
|
||||
static bool intersect(const LedgerEntrySet& lesLeft, const LedgerEntrySet& lesRight);
|
||||
};
|
||||
|
||||
@@ -415,7 +415,7 @@ BOOST_AUTO_TEST_SUITE( SHAMapSync )
|
||||
|
||||
BOOST_AUTO_TEST_CASE( SHAMapSync_test )
|
||||
{
|
||||
cLog(lsTRACE) << "being sync test";
|
||||
cLog(lsTRACE) << "begin sync test";
|
||||
unsigned int seed;
|
||||
RAND_pseudo_bytes(reinterpret_cast<unsigned char *>(&seed), sizeof(seed));
|
||||
srand(seed);
|
||||
|
||||
@@ -224,7 +224,6 @@ protected:
|
||||
: SerializedType(name), mCurrency(cur), mIssuer(iss), mValue(val), mOffset(off),
|
||||
mIsNative(isNat), mIsNegative(isNeg) { ; }
|
||||
|
||||
uint64 toUInt64() const;
|
||||
static uint64 muldiv(uint64, uint64, uint64);
|
||||
|
||||
public:
|
||||
@@ -287,6 +286,7 @@ public:
|
||||
|
||||
void negate() { if (!isZero()) mIsNegative = !mIsNegative; }
|
||||
void zero() { mOffset = mIsNative ? -100 : 0; mValue = 0; mIsNegative = false; }
|
||||
int compare(const STAmount&) const;
|
||||
|
||||
const uint160& getIssuer() const { return mIssuer; }
|
||||
void setIssuer(const uint160& uIssuer) { mIssuer = uIssuer; }
|
||||
|
||||
@@ -18,7 +18,7 @@ SETUP_LOG();
|
||||
void TransactionEngine::txnWrite()
|
||||
{
|
||||
// Write back the account states
|
||||
for (boost::unordered_map<uint256, LedgerEntrySetEntry>::iterator it = mNodes.begin(), end = mNodes.end();
|
||||
for (std::map<uint256, LedgerEntrySetEntry>::iterator it = mNodes.begin(), end = mNodes.end();
|
||||
it != end; ++it)
|
||||
{
|
||||
const SLE::pointer& sleEntry = it->second.mEntry;
|
||||
|
||||
Reference in New Issue
Block a user