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

This commit is contained in:
Arthur Britto
2013-02-11 22:02:53 -08:00
2 changed files with 33 additions and 14 deletions

View File

@@ -233,6 +233,20 @@ protected:
: SerializedType(name), mCurrency(cur), mIssuer(iss), mValue(val), mOffset(off), : SerializedType(name), mCurrency(cur), mIssuer(iss), mValue(val), mOffset(off),
mIsNative(isNat), mIsNegative(isNeg) { ; } mIsNative(isNat), mIsNegative(isNeg) { ; }
void set(int64_t v)
{
if (v < 0)
{
mIsNegative = true;
mValue = static_cast<uint64>(-v);
}
else
{
mIsNegative = false;
mValue = static_cast<uint64>(v);
}
}
public: public:
static const int cMinOffset = -96, cMaxOffset = 80; static const int cMinOffset = -96, cMaxOffset = 80;
static const uint64 cMinValue = 1000000000000000ull, cMaxValue = 9999999999999999ull; static const uint64 cMinValue = 1000000000000000ull, cMaxValue = 9999999999999999ull;
@@ -249,28 +263,33 @@ public:
: SerializedType(n), mValue(v), mOffset(0), mIsNative(true), mIsNegative(isNeg) : SerializedType(n), mValue(v), mOffset(0), mIsNative(true), mIsNegative(isNeg)
{ ; } { ; }
STAmount(SField::ref n, int64 v) STAmount(SField::ref n, int64 v) : SerializedType(n), mOffset(0), mIsNative(true)
: SerializedType(n), mOffset(0), mIsNative(true), mIsNegative(false) { set(v); }
{
if (v < 0)
{
mIsNegative = true;
mValue = static_cast<uint64_t>(-v);
}
else
mValue = static_cast<uint64_t>(v);
}
STAmount(const uint160& uCurrencyID, const uint160& uIssuerID, uint64 uV = 0, int iOff = 0, bool bNegative = false) STAmount(const uint160& uCurrencyID, const uint160& uIssuerID,
uint64 uV = 0, int iOff = 0, bool bNegative = false)
: mCurrency(uCurrencyID), mIssuer(uIssuerID), mValue(uV), mOffset(iOff), mIsNegative(bNegative) : mCurrency(uCurrencyID), mIssuer(uIssuerID), mValue(uV), mOffset(iOff), mIsNegative(bNegative)
{ canonicalize(); } { canonicalize(); }
// YYY This should probably require issuer too.
STAmount(SField::ref n, const uint160& currency, const uint160& issuer, STAmount(SField::ref n, const uint160& currency, const uint160& issuer,
uint64 v = 0, int off = 0, bool isNeg = false) : uint64 v = 0, int off = 0, bool isNeg = false) :
SerializedType(n), mCurrency(currency), mIssuer(issuer), mValue(v), mOffset(off), mIsNegative(isNeg) SerializedType(n), mCurrency(currency), mIssuer(issuer), mValue(v), mOffset(off), mIsNegative(isNeg)
{ canonicalize(); } { canonicalize(); }
STAmount(const uint160& uCurrencyID, const uint160& uIssuerID, int64 v, int iOff = 0)
: mCurrency(uCurrencyID), mIssuer(uIssuerID), mOffset(iOff)
{
set(v);
canonicalize();
}
STAmount(SField::ref n, const uint160& currency, const uint160& issuer, int64 v, int off = 0)
: SerializedType(n), mCurrency(currency), mIssuer(issuer), mOffset(off)
{
set(v);
canonicalize();
}
STAmount(SField::ref, const Json::Value&); STAmount(SField::ref, const Json::Value&);
static STAmount createFromInt64(SField::ref n, int64 v); static STAmount createFromInt64(SField::ref n, int64 v);

View File

@@ -56,7 +56,7 @@ protected:
mutable boost::recursive_mutex mLock; mutable boost::recursive_mutex mLock;
std::string mName; // Used for logging std::string mName; // Used for logging
unsigned int mTargetSize; // Desired number of cache entries (0 = ignore) int mTargetSize; // Desired number of cache entries (0 = ignore)
int mTargetAge; // Desired maximum cache age int mTargetAge; // Desired maximum cache age
int mCacheCount; // Number of items cached int mCacheCount; // Number of items cached