From e7d11e5b14151e49b548bf6891f1c6cbed9fbaee Mon Sep 17 00:00:00 2001 From: "Scott E. Graves" Date: Tue, 11 Apr 2017 13:41:21 -0500 Subject: [PATCH] Mo fixes --- htdocs/index.html | 2 +- htdocs/js/index.js | 4 ++-- include/siadrive_api/siacommon.h | 24 +++--------------------- src/siadrive_api/siacommon.cpp | 21 +++++++++++++++++++++ 4 files changed, 27 insertions(+), 24 deletions(-) diff --git a/htdocs/index.html b/htdocs/index.html index b4816f7..53c0e75 100644 --- a/htdocs/index.html +++ b/htdocs/index.html @@ -161,7 +161,7 @@

Your storage allowance automatically refills every 6 weeks. Your computer must be online with your wallet unlocked to complete the refill. If Sia fails to refill the allowance by the end of the lock-in period, your data may be lost.

*contract fees are non-refundable. They will be subtracted from the allowance that you set.

Allocated Funds

-

+  

Number of Hosts



Contract Period

diff --git a/htdocs/js/index.js b/htdocs/js/index.js index 898cc00..b79acc1 100644 --- a/htdocs/js/index.js +++ b/htdocs/js/index.js @@ -64,7 +64,7 @@ setValue('ID_RenterSetPeriod', allowance.Period); setValue('ID_RenterSetRenewWindow', allowance.RenewWindowInBlocks); AppActions.calculateEstimatedStorage(allowance.Funds, (res)=> { - setInnerText('ID_RenterCalcStorage', res); + setInnerText('ID_RenterCalcStorage', '~' + res); }); } } @@ -279,7 +279,7 @@ const funds = document.getElementById('ID_RenterSetFunds'); funds.oninput = () => { AppActions.calculateEstimatedStorage(funds.value, (res)=> { - setInnerText('ID_RenterCalcStorage', res); + setInnerText('ID_RenterCalcStorage', '~' + res); }); }; diff --git a/include/siadrive_api/siacommon.h b/include/siadrive_api/siacommon.h index 39143f8..a381265 100644 --- a/include/siadrive_api/siacommon.h +++ b/include/siadrive_api/siacommon.h @@ -90,9 +90,9 @@ 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 = 24; -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; +const std::uint32_t SIA_DEFAULT_RENEW_WINDOW = SIA_DEFAULT_CONTRACT_LENGTH / 3; #define DEFAULT_CONFIG_FILE_PATH L"./config/siadriveconfig.json" #define DEFAULT_RENTER_DB_FILE_PATH L"./config/renter_upload.db3" @@ -202,26 +202,8 @@ inline static SString SiaCurrencyToGB(const SiaCurrency& value) return value.ToWString(conv); } -inline static SString BytesToFriendlyDisplay(const SiaCurrency& bytes) -{ - SString units[] = { "B", "KB", "MB", "GB", "TB", "PB" }; - SString readableunit = "B"; - SiaCurrency readablesize = bytes; - for (const auto& unit : units) - { - if (readablesize < 1000) - { - readableunit = unit; - break; - } - readablesize /= 1000; - } - ttmath::Conv conv; - conv.scient_from = 256; - conv.base = 10; - conv.round = 2; - return readablesize.ToWString(conv) + ' ' + readableunit; -} + +SString SIADRIVE_EXPORTABLE BytesToFriendlyDisplay(const SiaCurrency& bytes); BOOL SIADRIVE_EXPORTABLE RetryAction(std::function func, std::uint16_t retryCount, const DWORD& retryDelay); diff --git a/src/siadrive_api/siacommon.cpp b/src/siadrive_api/siacommon.cpp index b1e2a59..d3924bb 100644 --- a/src/siadrive_api/siacommon.cpp +++ b/src/siadrive_api/siacommon.cpp @@ -148,6 +148,27 @@ BOOL RetryAction(std::function func, std::uint16_t retryCount, const DWO #endif } +SString BytesToFriendlyDisplay(const SiaCurrency& bytes) +{ + SString units[] = { "B", "KB", "MB", "GB", "TB", "PB" }; + SString readableunit = "B"; + SiaCurrency readablesize = bytes; + for (const auto& unit : units) + { + if (readablesize < 1000) + { + readableunit = unit; + break; + } + readablesize /= 1000; + } + ttmath::Conv conv; + conv.scient_from = 256; + conv.base = 10; + conv.round = 2; + return readablesize.ToWString(conv) + ' ' + readableunit; +} + #ifdef _WIN32 std::vector GetAvailableDrives() {