59 lines
1.0 KiB
C++
59 lines
1.0 KiB
C++
#include "stdafx.h"
|
|
#include "SiaApi.h"
|
|
#include <regex>
|
|
#include "SiaDriveConfig.h"
|
|
|
|
using namespace Sia::Api;
|
|
|
|
CSiaApi::CSiaApi(const SiaHostConfig& hostConfig, CSiaDriveConfig* siaDriveConfig) :
|
|
_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;
|
|
} |