36 lines
719 B
C++
36 lines
719 B
C++
#include "stdafx.h"
|
|
#include "SiaApi.h"
|
|
|
|
using namespace Sia::Api;
|
|
|
|
CSiaApi::_CSiaConsensus::_CSiaConsensus(const CSiaCurl& siaCurl) :
|
|
CSiaBase(siaCurl),
|
|
CAutoThread(siaCurl),
|
|
_Height(0),
|
|
_Synced(false),
|
|
_CurrentBlock(L"")
|
|
{
|
|
StartAutoThread();
|
|
}
|
|
|
|
CSiaApi::_CSiaConsensus::~_CSiaConsensus()
|
|
{
|
|
StopAutoThread();
|
|
}
|
|
|
|
void CSiaApi::_CSiaConsensus::AutoThreadCallback(const CSiaCurl& siaCurl)
|
|
{
|
|
json result;
|
|
if (ApiSuccess(siaCurl.Get(L"/consensus", result)))
|
|
{
|
|
SetHeight(result["height"].get<std::uint64_t>());
|
|
SetSynced(result["synced"].get<bool>());
|
|
SetCurrentBlock(CA2W(result["currentblock"].get<std::string>().c_str()).m_psz);
|
|
}
|
|
else
|
|
{
|
|
SetHeight(0);
|
|
SetSynced(false);
|
|
SetCurrentBlock(L"");
|
|
}
|
|
} |