-
-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
WIP Add REST-like API calls for daemon, hardware info (#145)
* add rest-like api for daemon * add transactions by payment_id to rest-like api * add transaction info in JSON by hash renamed k_transaction_details_by_hash to gettransaction * bugfixes * Update version.h.in * add brain sources * minor codestyle fixes * Add mempool to Restful like Api & improve get_transactions_by_heights Method * Add mempool_details to restful like Api Renamed f_mempool_json to get_mempool_detailed * version.h.in aktualisiert * Avoid needing of parsing on end device * Add fee to get_transactions_by_heights & adjusted REST API Mempool * Fix internal error to search for a block heigher than actuall chain height * Update Currency.cpp * Increase nextDiffV5 to pre6 Version * add rest-like api for daemon * add transactions by payment_id to rest-like api * add transaction info in JSON by hash renamed k_transaction_details_by_hash to gettransaction * bugfixes * add brain sources * minor codestyle fixes * Add mempool to Restful like Api & improve get_transactions_by_heights Method * Add mempool_details to restful like Api Renamed f_mempool_json to get_mempool_detailed * Avoid needing of parsing on end device * Add fee to get_transactions_by_heights & adjusted REST API Mempool * Fix internal error to search for a block heigher than actuall chain height * Bum Version * Bump Version * Fix output indices * Cleanup RPC a bit * Add method to get txs by height * Add improved onGetRawTransactionsByHeights from @aivve * Add HardwareInfo * Update Checkpoints.h, CryptoNoteConfig.h, and version.h.in * Update CMakeLists.txt * Update NetNode.cpp * add core/threadCount on Windows and MacOS * Add architecture to RPCServer, changed output to string * Add Memory to HardwareInfo and RPCServer * Add Storage to HardwareInfo, cleanup gethardwareinfo RPC command * Update HardwareInfo.cpp Co-authored-by: ExploShot <[email protected]>
- Loading branch information
Showing
21 changed files
with
5,830 additions
and
4,474 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,143 @@ | ||
// | ||
// Created by exploshot on 12.10.20. | ||
// | ||
|
||
#ifndef _WIN32 | ||
|
||
#include <algorithm> | ||
#include <cstdlib> | ||
#include <cstring> | ||
#include <fstream> | ||
#include <string> | ||
#include <sys/utsname.h> | ||
#include <unistd.h> | ||
|
||
#endif | ||
|
||
#ifdef _WIN32 | ||
|
||
#define WIN32_LEAN_AND_MEAN | ||
#include <thread> | ||
#include <windows.h> | ||
|
||
#endif | ||
|
||
#if __APPLE__ | ||
#include <sys/param.h> | ||
#include <sys/sysctl.h> | ||
#endif | ||
|
||
#include <vector> | ||
|
||
#include <Common/HardwareInfo.h> | ||
|
||
using namespace Tools::CPU; | ||
|
||
#ifdef _WIN32 | ||
|
||
static std::vector<SYSTEM_LOGICAL_PROCESSOR_INFORMATION> cpuinfoBuffer() | ||
{ | ||
std::vector<SYSTEM_LOGICAL_PROCESSOR_INFORMATION> buffer; | ||
|
||
DWORD byte_count = 0; | ||
GetLogicalProcessorInformation(nullptr, &byte_count); | ||
buffer.resize(byte_count / sizeof(SYSTEM_LOGICAL_PROCESSOR_INFORMATION)); | ||
GetLogicalProcessorInformation(buffer.data(), &byte_count); | ||
|
||
return buffer; | ||
} | ||
|
||
#endif | ||
|
||
std::string Tools::CPU::architecture() noexcept | ||
{ | ||
#ifdef _WIN32 | ||
SYSTEM_INFO sysInfo; | ||
GetSystemInfo(&sysInfo); | ||
|
||
switch (sysInfo.wProcessorArchitecture) | ||
{ | ||
case PROCESSOR_ARCHITECTURE_AMD64: | ||
return "x64"; | ||
case PROCESSOR_ARCHITECTURE_ARM: | ||
return "ARM"; | ||
case PROCESSOR_ARCHITECTURE_IA64: | ||
return "Itanium"; | ||
case PROCESSOR_ARCHITECTURE_INTEL: | ||
return "x86"; | ||
default: | ||
return "unknown"; | ||
} | ||
#endif | ||
|
||
#ifndef _WIN32 | ||
utsname buf; | ||
if (uname(&buf) == -1) { | ||
return "unknown"; | ||
} | ||
|
||
if (!strcmp(buf.machine, "x86_64")) | ||
return "x64"; | ||
else if (strstr(buf.machine, "arm") == buf.machine) | ||
return "ARM"; | ||
else if (!strcmp(buf.machine, "ia64") || !strcmp(buf.machine, "IA64")) | ||
return "Itanium"; | ||
else if (!strcmp(buf.machine, "i686")) | ||
return "x86"; | ||
else | ||
return "unknown"; | ||
#endif | ||
} | ||
|
||
Tools::CPU::Quantities Tools::CPU::quantities() | ||
{ | ||
Quantities ret{}; | ||
|
||
#ifdef _WIN32 | ||
SYSTEM_INFO sysinfo; | ||
GetSystemInfo(&sysinfo); | ||
ret.logical = sysinfo.dwNumberOfProcessors; | ||
ret.physical = ret.logical / 2; | ||
#elif __APPLE__ | ||
int nm[2]; | ||
size_t len = 4; | ||
uint32_t count; | ||
|
||
nm[0] = CTL_HW; nm[1] = HW_AVAILCPU; | ||
sysctl(nm, 2, &count, &len, NULL, 0); | ||
|
||
if(count < 1) { | ||
nm[1] = HW_NCPU; | ||
sysctl(nm, 2, &count, &len, NULL, 0); | ||
if(count < 1) { count = 1; } | ||
} | ||
ret.logical = count; | ||
ret.physical = ret.logical / 2; | ||
#else | ||
ret.logical = sysconf(_SC_NPROCESSORS_ONLN); | ||
|
||
std::ifstream cpuinfo("/proc/cpuinfo"); | ||
|
||
if (!cpuinfo.is_open() || !cpuinfo) { | ||
return ret; | ||
} | ||
|
||
std::vector<unsigned int> packageIds; | ||
for (std::string line; std::getline(cpuinfo, line);) { | ||
if (line.find("physical id") == 0) { | ||
const auto physicalId = std::strtoul(line.c_str() + line.find_first_of("1234567890"), nullptr, 10); | ||
if (std::find(packageIds.begin(), packageIds.end(), physicalId) == packageIds.end()) { | ||
packageIds.emplace_back(physicalId); | ||
} | ||
} | ||
} | ||
|
||
ret.packages = packageIds.size(); | ||
ret.physical = ret.logical / ret.packages; | ||
#endif | ||
return ret; | ||
} | ||
|
||
|
||
|
||
|
Oops, something went wrong.