1
0

Renter allowance changes

This commit is contained in:
Scott E. Graves
2017-03-28 18:35:39 -05:00
parent ffaf818e5f
commit 8d0b76e378
6 changed files with 107 additions and 11 deletions

View File

@@ -144,6 +144,15 @@ public:
{
friend CSiaApi;
public:
typedef struct
{
SiaCurrency Funds;
std::uint64_t Hosts;
std::uint64_t Period;
std::uint64_t RenewWindowInBlocks;
} _SiaRenterAllowance;
private:
explicit _CSiaRenter(const CSiaCurl& siaCurl, CSiaDriveConfig* siaDriveConfig);
@@ -155,8 +164,11 @@ public:
Property(SiaCurrency, Unspent, public, private)
Property(std::uint64_t, TotalUsedBytes, public, private)
Property(std::uint32_t, TotalUploadProgress, public, private)
Property(std::uint64_t, Period, public, private)
Property(std::uint64_t, RenewWindow, public, private)
private:
_SiaRenterAllowance _currentAllowance;
std::shared_ptr<_CSiaFileTree> _fileTree;
std::mutex _fileTreeMutex;
@@ -167,6 +179,8 @@ public:
_SiaApiError FileExists(const SString& siaPath, bool& exists) const;
_SiaApiError DownloadFile(const SString& siaPath, const SString& location) const;
_SiaApiError GetFileTree(std::shared_ptr<_CSiaFileTree>& siaFileTree) const;
_SiaRenterAllowance GetAllowance() const;
_SiaApiError SetAllowance(const _SiaRenterAllowance& renterAllowance);
};
class SIADRIVE_EXPORTABLE _CSiaConsensus :
@@ -222,6 +236,7 @@ typedef CSiaApi::_SiaApiError SiaApiError;
typedef CSiaApi::_SiaSeedLanguage SiaSeedLanguage;
typedef CSiaApi::_CSiaWallet CSiaWallet;
typedef CSiaApi::_CSiaRenter CSiaRenter;
typedef CSiaRenter::_SiaRenterAllowance SiaRenterAllowance;
typedef CSiaApi::_CSiaConsensus CSiaConsensus;
typedef std::shared_ptr<CSiaWallet> CSiaWalletPtr;
typedef std::shared_ptr<CSiaRenter> CSiaRenterPtr;
@@ -231,6 +246,5 @@ typedef std::shared_ptr<CSiaFile> CSiaFilePtr;
typedef std::vector<CSiaFilePtr> CSiaFileCollection;
typedef CSiaApi::_CSiaFileTree CSiaFileTree;
typedef std::shared_ptr<CSiaFileTree> CSiaFileTreePtr;
NS_END(2)
#endif //_SIAAPI_H

View File

@@ -1,12 +1,18 @@
#ifndef _SIACOMMON_H
#define _SIACOMMON_H
#include <cstdint>
#define SIDRIVE_VERSION_STRING "0.0.1"
#define COMPAT_SIAD_VERSION "1.1.2"
const std::uint8_t SIA_BLOCKS_PER_MIN = 10;
const std::uint32_t MINUTES_PER_MONTH = (730 * 60);
const std::uint32_t SIA_BLOCKS_PER_MONTH = MINUTES_PER_MONTH / SIA_BLOCKS_PER_MIN;
#ifdef _WIN32
// Disable DLL-interface warnings
#pragma warning(disable: 4251)
#pragma warning(disable: 4275)
// Unicode for Win32
#define UNICODE
@@ -110,6 +116,7 @@ inline bool ApiSuccess(const T& t) {
typedef ttmath::UInt<256> Hastings;
typedef ttmath::Big<1, 30> SiaCurrency;
/*
BigNumber.config({ EXPONENTIAL_AT: 1e+9 })
BigNumber.config({ DECIMAL_PLACES: 30 })
@@ -121,7 +128,7 @@ const hastingsToSiacoins = (hastings) => new BigNumber(hastings).dividedBy(hasti
inline static SiaCurrency HastingsStringToSiaCurrency(const SString& value)
{
ttmath::Parser<SiaCurrency> parser;
parser.Parse((value + " / (10^24)").str());
parser.Parse((value + " / (10 ^ 24)").str());
return parser.stack[0].value;
}
@@ -134,6 +141,17 @@ inline static SString SiaCurrencyToString(const SiaCurrency& value)
return value.ToWString(conv);
}
inline static SString SiaCurrencyToHastingsString(const SiaCurrency& value)
{
ttmath::Parser<SiaCurrency> parser;
parser.Parse(value.ToString() + " * (10 ^ 24)");
ttmath::Conv conv;
conv.base = 10;
conv.round = 0;
return parser.stack[0].value.ToWString(conv);
}
inline static SString SiaCurrencyToGB(const SiaCurrency& value)
{
ttmath::Conv conv;