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

This commit is contained in:
Arthur Britto
2012-12-11 19:48:06 -08:00
5 changed files with 37 additions and 16 deletions

View File

@@ -15,6 +15,8 @@
SETUP_LOG();
uint64 STAmount::uRateOne = STAmount::getRate(STAmount(1), STAmount(1));
static const uint64_t tenTo16 = 10000000000000000ul;
static const uint64_t tenTo18 = 1000000000000000000ul;
bool STAmount::issuerFromString(uint160& uDstIssuer, const std::string& sIssuer)
{
@@ -900,7 +902,7 @@ STAmount STAmount::divide(const STAmount& num, const STAmount& den, const uint16
// Compute (numerator * 10^16) / denominator
CBigNum v;
if ((BN_add_word(&v, numVal) != 1) ||
(BN_mul_word(&v, 10000000000000000ul) != 1) ||
(BN_mul_word(&v, tenTo16) != 1) ||
(BN_div_word(&v, denVal) == ((BN_ULONG) -1)))
{
throw std::runtime_error("internal bn error");
@@ -953,9 +955,9 @@ STAmount STAmount::multiply(const STAmount& v1, const STAmount& v2, const uint16
// Compute (numerator*10 * denominator*10) / 10^18 with rounding
CBigNum v;
if ((BN_add_word(&v, value1) != 1) ||
(BN_mul_word(&v, value2) != 1) ||
(BN_div_word(&v, 100000000000000ul) == ((BN_ULONG) -1)))
if ((BN_add_word(&v, value1 * 10 + 3) != 1) ||
(BN_mul_word(&v, value2 * 10 + 3) != 1) ||
(BN_div_word(&v, tenTo18) == ((BN_ULONG) -1)))
{
throw std::runtime_error("internal bn error");
}
@@ -963,7 +965,7 @@ STAmount STAmount::multiply(const STAmount& v1, const STAmount& v2, const uint16
// 10^16 <= product <= 10^18
assert(BN_num_bytes(&v) <= 64);
return STAmount(uCurrencyID, uIssuerID, v.getulong(), offset1 + offset2 + 14, v1.mIsNegative != v2.mIsNegative);
return STAmount(uCurrencyID, uIssuerID, v.getulong(), offset1 + offset2 + 16, v1.mIsNegative != v2.mIsNegative);
}
// Convert an offer into an index amount so they sort by rate.
@@ -1116,8 +1118,8 @@ uint64 STAmount::muldiv(uint64 a, uint64 b, uint64 c)
if ((a == 0) || (b == 0)) return 0;
CBigNum v;
if ((BN_add_word(&v, a * 10) != 1) ||
(BN_mul_word(&v, b * 10) != 1) ||
if ((BN_add_word(&v, a * 10 + 3) != 1) ||
(BN_mul_word(&v, b * 10 + 3) != 1) ||
(BN_add_word(&v, 50) != 1) ||
(BN_div_word(&v, c) == ((BN_ULONG) -1)) ||
(BN_div_word(&v, 100) == ((BN_ULONG) -1)))

View File

@@ -48,7 +48,7 @@
// Fees are in XRP.
#define DEFAULT_FEE_DEFAULT 10
#define DEFAULT_FEE_ACCOUNT_CREATE 1000*SYSTEM_CURRENCY_PARTS
#define DEFAULT_FEE_ACCOUNT_CREATE 200*SYSTEM_CURRENCY_PARTS
#define DEFAULT_FEE_NICKNAME_CREATE 1000
#define DEFAULT_FEE_OFFER DEFAULT_FEE_DEFAULT
#define DEFAULT_FEE_OPERATION 1

View File

@@ -1,7 +1,8 @@
#include "LoadManager.h"
LoadManager::LoadManager(int creditRate, int creditLimit, int debitWarn, int debitLimit) :
mCreditRate(creditRate), mCreditLimit(creditLimit), mDebitWarn(debitWarn), mDebitLimit(debitLimit), mCosts(LT_MAX)
mCreditRate(creditRate), mCreditLimit(creditLimit), mDebitWarn(debitWarn), mDebitLimit(debitLimit),
mCosts(LT_MAX)
{
addLoadCost(LoadCost(LT_InvalidRequest, 10, LC_CPU | LC_Network));
addLoadCost(LoadCost(LT_RequestNoReply, 1, LC_CPU | LC_Disk));

View File

@@ -26,10 +26,10 @@ enum LoadType
LT_RequestData, // A request that is hard to satisfy, disk access
LT_CheapQuery, // A query that is trivial, cached data
LT_MAX = LT_CheapQuery
LT_MAX // MUST BE LAST
};
// load categoryies
// load categories
static const int LC_Disk = 1;
static const int LC_CPU = 2;
static const int LC_Network = 4;