#include "stdafx.h" #include "SiaApi.h" #include #include "SiaDriveConfig.h" using namespace Sia::Api; CSiaApi::CSiaApi(const SiaHostConfig& hostConfig, CSiaDriveConfig* siaDriveConfig) : _hostConfig(hostConfig), _siaCurl(hostConfig), _siaDriveConfig(siaDriveConfig), _wallet(new CSiaWallet(_siaCurl, siaDriveConfig)), _renter(new CSiaRenter(_siaCurl, siaDriveConfig)), _consensus(new CSiaConsensus(_siaCurl, siaDriveConfig)) { } CSiaApi::~CSiaApi() { //TODO Make this an option to lock on exit //_wallet->Lock(); } String CSiaApi::FormatToSiaPath(String path) { if (path.length()) { std::replace(path.begin(), path.end(), '\\', '/'); std::wregex r(L"/+"); path = std::regex_replace(path, r, L"/"); while (path[0] == '/') { path = path.substr(1); } } return path; } String CSiaApi::GetServerVersion() const { return _siaCurl.GetServerVersion(); } CSiaWalletPtr CSiaApi::GetWallet() const { return _wallet; } CSiaRenterPtr CSiaApi::GetRenter() const { return _renter; } CSiaConsensusPtr CSiaApi::GetConsensus() const { return _consensus; } SiaHostConfig CSiaApi::GetHostConfig() const { return _hostConfig; }