1
0
This repository has been archived on 2025-07-27. You can view files and clone it, but cannot push or open issues or pull requests.
Files
siadrive/SiaDrive.Api/SiaApi.cpp
2017-02-25 20:48:27 -06:00

65 lines
1.1 KiB
C++

#include "stdafx.h"
#include "SiaApi.h"
#include <regex>
#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;
}