From a933bb960a6067b9ead54d6642e3a7d3aee27a95 Mon Sep 17 00:00:00 2001 From: "Scott E. Graves" Date: Thu, 30 Mar 2017 14:44:57 -0500 Subject: [PATCH] Renter settings --- include/siadrive_api/siacommon.h | 34 +++++++++++++------------------- src/siadrive/siadriveapp.cpp | 5 +++++ 2 files changed, 19 insertions(+), 20 deletions(-) diff --git a/include/siadrive_api/siacommon.h b/include/siadrive_api/siacommon.h index b6cf58b..4fc624e 100644 --- a/include/siadrive_api/siacommon.h +++ b/include/siadrive_api/siacommon.h @@ -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(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 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) diff --git a/src/siadrive/siadriveapp.cpp b/src/siadrive/siadriveapp.cpp index 6155226..bc26065 100644 --- a/src/siadrive/siadriveapp.cpp +++ b/src/siadrive/siadriveapp.cpp @@ -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;