mirror of
https://github.com/xmrig/xmrig.git
synced 2025-01-24 19:46:15 +00:00
Rename Results => NetworkState.
This commit is contained in:
parent
9e9cddedc5
commit
8e08df2fd2
9 changed files with 34 additions and 33 deletions
|
@ -12,7 +12,7 @@ set(HEADERS
|
||||||
src/3rdparty/align.h
|
src/3rdparty/align.h
|
||||||
src/api/Api.h
|
src/api/Api.h
|
||||||
src/api/ApiState.h
|
src/api/ApiState.h
|
||||||
src/api/Results.h
|
src/api/NetworkState.h
|
||||||
src/App.h
|
src/App.h
|
||||||
src/Console.h
|
src/Console.h
|
||||||
src/Cpu.h
|
src/Cpu.h
|
||||||
|
@ -65,7 +65,7 @@ set(HEADERS_CRYPTO
|
||||||
set(SOURCES
|
set(SOURCES
|
||||||
src/api/Api.cpp
|
src/api/Api.cpp
|
||||||
src/api/ApiState.cpp
|
src/api/ApiState.cpp
|
||||||
src/api/Results.cpp
|
src/api/NetworkState.cpp
|
||||||
src/App.cpp
|
src/App.cpp
|
||||||
src/Console.cpp
|
src/Console.cpp
|
||||||
src/log/ConsoleLog.cpp
|
src/log/ConsoleLog.cpp
|
||||||
|
|
|
@ -81,13 +81,13 @@ void Api::tick(const Hashrate *hashrate)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Api::tick(const Results &results)
|
void Api::tick(const NetworkState &network)
|
||||||
{
|
{
|
||||||
if (!m_state) {
|
if (!m_state) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
uv_mutex_lock(&m_mutex);
|
uv_mutex_lock(&m_mutex);
|
||||||
m_state->tick(results);
|
m_state->tick(network);
|
||||||
uv_mutex_unlock(&m_mutex);
|
uv_mutex_unlock(&m_mutex);
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,7 +30,7 @@
|
||||||
|
|
||||||
class ApiState;
|
class ApiState;
|
||||||
class Hashrate;
|
class Hashrate;
|
||||||
class Results;
|
class NetworkState;
|
||||||
|
|
||||||
|
|
||||||
class Api
|
class Api
|
||||||
|
@ -41,7 +41,7 @@ public:
|
||||||
|
|
||||||
static const char *get(const char *url, size_t *size, int *status);
|
static const char *get(const char *url, size_t *size, int *status);
|
||||||
static void tick(const Hashrate *hashrate);
|
static void tick(const Hashrate *hashrate);
|
||||||
static void tick(const Results &results);
|
static void tick(const NetworkState &results);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static ApiState *m_state;
|
static ApiState *m_state;
|
||||||
|
|
|
@ -112,9 +112,9 @@ void ApiState::tick(const Hashrate *hashrate)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ApiState::tick(const Results &results)
|
void ApiState::tick(const NetworkState &network)
|
||||||
{
|
{
|
||||||
m_results = results;
|
m_network = network;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -216,14 +216,15 @@ void ApiState::getResults(json_t *reply) const
|
||||||
json_t *results = json_object();
|
json_t *results = json_object();
|
||||||
json_t *best = json_array();
|
json_t *best = json_array();
|
||||||
|
|
||||||
json_object_set(reply, "results", results);
|
json_object_set(reply, "results", results);
|
||||||
json_object_set(results, "diff_current", json_integer(m_results.diff));
|
json_object_set(results, "diff_current", json_integer(m_network.diff));
|
||||||
json_object_set(results, "shares_good", json_integer(m_results.accepted));
|
json_object_set(results, "shares_good", json_integer(m_network.accepted));
|
||||||
json_object_set(results, "shares_total", json_integer(m_results.accepted + m_results.rejected));
|
json_object_set(results, "shares_total", json_integer(m_network.accepted + m_network.rejected));
|
||||||
json_object_set(results, "hashes_total", json_integer(m_results.total));
|
json_object_set(results, "hashes_total", json_integer(m_network.total));
|
||||||
json_object_set(results, "best", best);
|
json_object_set(results, "best", best);
|
||||||
|
json_object_set(results, "error_log", json_array());
|
||||||
|
|
||||||
for (size_t i = 0; i < m_results.topDiff.size(); ++i) {
|
for (size_t i = 0; i < m_network.topDiff.size(); ++i) {
|
||||||
json_array_append(best, json_integer(m_results.topDiff[i]));
|
json_array_append(best, json_integer(m_network.topDiff[i]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,7 +25,7 @@
|
||||||
#define __APISTATE_H__
|
#define __APISTATE_H__
|
||||||
|
|
||||||
|
|
||||||
#include "api/Results.h"
|
#include "api/NetworkState.h"
|
||||||
#include "jansson.h"
|
#include "jansson.h"
|
||||||
|
|
||||||
|
|
||||||
|
@ -40,7 +40,7 @@ public:
|
||||||
|
|
||||||
const char *get(const char *url, size_t *size) const;
|
const char *get(const char *url, size_t *size) const;
|
||||||
void tick(const Hashrate *hashrate);
|
void tick(const Hashrate *hashrate);
|
||||||
void tick(const Results &results);
|
void tick(const NetworkState &results);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const char *finalize(json_t *reply, size_t *size) const;
|
const char *finalize(json_t *reply, size_t *size) const;
|
||||||
|
@ -58,7 +58,7 @@ private:
|
||||||
double m_totalHashrate[3];
|
double m_totalHashrate[3];
|
||||||
int m_threads;
|
int m_threads;
|
||||||
mutable char m_buf[4096];
|
mutable char m_buf[4096];
|
||||||
Results m_results;
|
NetworkState m_network;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* __APISTATE_H__ */
|
#endif /* __APISTATE_H__ */
|
||||||
|
|
|
@ -25,11 +25,11 @@
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
|
|
||||||
#include "api/Results.h"
|
#include "api/NetworkState.h"
|
||||||
#include "net/SubmitResult.h"
|
#include "net/SubmitResult.h"
|
||||||
|
|
||||||
|
|
||||||
void Results::add(const SubmitResult &result, const char *error)
|
void NetworkState::add(const SubmitResult &result, const char *error)
|
||||||
{
|
{
|
||||||
if (error) {
|
if (error) {
|
||||||
rejected++;
|
rejected++;
|
|
@ -21,8 +21,8 @@
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef __RESULTS_H__
|
#ifndef __NETWORKSTATE_H__
|
||||||
#define __RESULTS_H__
|
#define __NETWORKSTATE_H__
|
||||||
|
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
@ -32,10 +32,10 @@
|
||||||
class SubmitResult;
|
class SubmitResult;
|
||||||
|
|
||||||
|
|
||||||
class Results
|
class NetworkState
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
inline Results() :
|
inline NetworkState() :
|
||||||
diff(0),
|
diff(0),
|
||||||
accepted(0),
|
accepted(0),
|
||||||
rejected(0),
|
rejected(0),
|
||||||
|
@ -51,4 +51,4 @@ public:
|
||||||
uint64_t total;
|
uint64_t total;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* __RESULTS_H__ */
|
#endif /* __NETWORKSTATE_H__ */
|
|
@ -141,17 +141,17 @@ void Network::onPause(IStrategy *strategy)
|
||||||
|
|
||||||
void Network::onResultAccepted(Client *client, const SubmitResult &result, const char *error)
|
void Network::onResultAccepted(Client *client, const SubmitResult &result, const char *error)
|
||||||
{
|
{
|
||||||
m_results.add(result, error);
|
m_state.add(result, error);
|
||||||
|
|
||||||
if (error) {
|
if (error) {
|
||||||
LOG_INFO(m_options->colors() ? "\x1B[01;31mrejected\x1B[0m (%" PRId64 "/%" PRId64 ") diff \x1B[01;37m%u\x1B[0m \x1B[31m\"%s\"\x1B[0m \x1B[01;30m(%" PRIu64 " ms)"
|
LOG_INFO(m_options->colors() ? "\x1B[01;31mrejected\x1B[0m (%" PRId64 "/%" PRId64 ") diff \x1B[01;37m%u\x1B[0m \x1B[31m\"%s\"\x1B[0m \x1B[01;30m(%" PRIu64 " ms)"
|
||||||
: "rejected (%" PRId64 "/%" PRId64 ") diff %u \"%s\" (%" PRIu64 " ms)",
|
: "rejected (%" PRId64 "/%" PRId64 ") diff %u \"%s\" (%" PRIu64 " ms)",
|
||||||
m_results.accepted, m_results.rejected, result.diff, error, result.elapsed);
|
m_state.accepted, m_state.rejected, result.diff, error, result.elapsed);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
LOG_INFO(m_options->colors() ? "\x1B[01;32maccepted\x1B[0m (%" PRId64 "/%" PRId64 ") diff \x1B[01;37m%u\x1B[0m \x1B[01;30m(%" PRIu64 " ms)"
|
LOG_INFO(m_options->colors() ? "\x1B[01;32maccepted\x1B[0m (%" PRId64 "/%" PRId64 ") diff \x1B[01;37m%u\x1B[0m \x1B[01;30m(%" PRIu64 " ms)"
|
||||||
: "accepted (%" PRId64 "/%" PRId64 ") diff %u (%" PRIu64 " ms)",
|
: "accepted (%" PRId64 "/%" PRId64 ") diff %u (%" PRIu64 " ms)",
|
||||||
m_results.accepted, m_results.rejected, result.diff, result.elapsed);
|
m_state.accepted, m_state.rejected, result.diff, result.elapsed);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -165,7 +165,7 @@ void Network::setJob(Client *client, const Job &job)
|
||||||
LOG_INFO("new job from %s:%d diff %d", client->host(), client->port(), job.diff());
|
LOG_INFO("new job from %s:%d diff %d", client->host(), client->port(), job.diff());
|
||||||
}
|
}
|
||||||
|
|
||||||
m_results.diff = job.diff();
|
m_state.diff = job.diff();
|
||||||
Workers::setJob(job);
|
Workers::setJob(job);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -180,7 +180,7 @@ void Network::tick()
|
||||||
m_donate->tick(now);
|
m_donate->tick(now);
|
||||||
}
|
}
|
||||||
|
|
||||||
Api::tick(m_results);
|
Api::tick(m_state);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -29,7 +29,7 @@
|
||||||
#include <uv.h>
|
#include <uv.h>
|
||||||
|
|
||||||
|
|
||||||
#include "api/Results.h"
|
#include "api/NetworkState.h"
|
||||||
#include "interfaces/IJobResultListener.h"
|
#include "interfaces/IJobResultListener.h"
|
||||||
#include "interfaces/IStrategyListener.h"
|
#include "interfaces/IStrategyListener.h"
|
||||||
|
|
||||||
|
@ -66,7 +66,7 @@ private:
|
||||||
const Options *m_options;
|
const Options *m_options;
|
||||||
IStrategy *m_donate;
|
IStrategy *m_donate;
|
||||||
IStrategy *m_strategy;
|
IStrategy *m_strategy;
|
||||||
Results m_results;
|
NetworkState m_state;
|
||||||
uv_timer_t m_timer;
|
uv_timer_t m_timer;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue