1
0

Renter settings

This commit is contained in:
Scott E. Graves
2017-03-30 14:44:57 -05:00
parent 5bc42b1fd4
commit a933bb960a
2 changed files with 19 additions and 20 deletions

View File

@@ -81,6 +81,17 @@ public:
}
};
typedef ttmath::UInt<256> Hastings;
typedef ttmath::Big<1, 30> SiaCurrency;
const std::uint8_t SIA_BLOCK_TIME_MINS = 10;
const std::uint32_t MINUTES_PER_MONTH = (730 * 60);
const std::uint32_t SIA_BLOCKS_PER_MONTH = MINUTES_PER_MONTH / SIA_BLOCK_TIME_MINS;
const std::uint32_t SIA_DEFAULT_HOST_COUNT = 50;
const std::uint32_t SIA_DEFAULT_RENEW_WINDOW = ((1440 / SIA_BLOCK_TIME_MINS) * 14);
const SiaCurrency SIA_DEFAULT_MINIMUM_FUNDS = 4000;
const std::uint32_t SIA_DEFAULT_CONTRACT_LENGTH = SIA_BLOCKS_PER_MONTH * 3;
#define DEFAULT_CONFIG_FILE_PATH L"./config/siadriveconfig.json"
#define DEFAULT_RENTER_DB_FILE_PATH L"./config/renter_upload.db3"
@@ -140,25 +151,6 @@ inline bool ApiSuccess(const T& t) {
return static_cast<bool>(t);
}
typedef ttmath::UInt<256> Hastings;
typedef ttmath::Big<1, 30> SiaCurrency;
const std::uint8_t SIA_BLOCK_TIME_MINS = 10;
const std::uint32_t MINUTES_PER_MONTH = (730 * 60);
const std::uint32_t SIA_BLOCKS_PER_MONTH = MINUTES_PER_MONTH / SIA_BLOCK_TIME_MINS;
const std::uint32_t SIA_DEFAULT_HOST_COUNT = 50;
const std::uint32_t SIA_DEFAULT_RENEW_WINDOW = ((1440 / SIA_BLOCK_TIME_MINS) * 14);
const SiaCurrency SIA_DEFAULT_MINIMUM_FUNDS = 4000;
const std::uint32_t SIA_DEFAULT_CONTRACT_LENGTH = SIA_BLOCKS_PER_MONTH * 3;
/*
BigNumber.config({ EXPONENTIAL_AT: 1e+9 })
BigNumber.config({ DECIMAL_PLACES: 30 })
const hastingsPerSiacoin = new BigNumber('10').toPower(24)
const siacoinsToHastings = (siacoins) => new BigNumber(siacoins).times(hastingsPerSiacoin)
const hastingsToSiacoins = (hastings) => new BigNumber(hastings).dividedBy(hastingsPerSiacoin)
*/
inline static SiaCurrency HastingsStringToSiaCurrency(const SString& value)
{
ttmath::Parser<SiaCurrency> parser;
@@ -181,9 +173,11 @@ inline static SString SiaCurrencyToHastingsString(const SiaCurrency& value)
parser.Parse(value.ToString() + " * (10 ^ 24)");
ttmath::Conv conv;
conv.scient_from = 256;
conv.base = 10;
conv.round = 0;
return parser.stack[0].value.ToWString(conv);
SString ret = parser.stack[0].value.ToWString(conv);
return ret;
}
inline static SString SiaCurrencyToGB(const SiaCurrency& value)

View File

@@ -200,6 +200,11 @@ public:
});
auto ret = _siaApi.GetRenter()->SetAllowance(allowance);
CefV8ValueList args;
args.push_back(CefV8Value::CreateBool(ApiSuccess(ret)));
args.push_back(CefV8Value::CreateString(ret.GetReason().str()));
cb->ExecuteFunctionWithContext(context, nullptr, args);
return true;
}
// Function does not exist.
return false;