Rename Results => NetworkState.

This commit is contained in:
XMRig 2017-09-01 15:35:00 +03:00
parent 9e9cddedc5
commit 8e08df2fd2
9 changed files with 34 additions and 33 deletions

View file

@ -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) {
return;
}
uv_mutex_lock(&m_mutex);
m_state->tick(results);
m_state->tick(network);
uv_mutex_unlock(&m_mutex);
}

View file

@ -30,7 +30,7 @@
class ApiState;
class Hashrate;
class Results;
class NetworkState;
class Api
@ -41,7 +41,7 @@ public:
static const char *get(const char *url, size_t *size, int *status);
static void tick(const Hashrate *hashrate);
static void tick(const Results &results);
static void tick(const NetworkState &results);
private:
static ApiState *m_state;

View file

@ -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 *best = json_array();
json_object_set(reply, "results", results);
json_object_set(results, "diff_current", json_integer(m_results.diff));
json_object_set(results, "shares_good", json_integer(m_results.accepted));
json_object_set(results, "shares_total", json_integer(m_results.accepted + m_results.rejected));
json_object_set(results, "hashes_total", json_integer(m_results.total));
json_object_set(results, "best", best);
json_object_set(reply, "results", results);
json_object_set(results, "diff_current", json_integer(m_network.diff));
json_object_set(results, "shares_good", json_integer(m_network.accepted));
json_object_set(results, "shares_total", json_integer(m_network.accepted + m_network.rejected));
json_object_set(results, "hashes_total", json_integer(m_network.total));
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) {
json_array_append(best, json_integer(m_results.topDiff[i]));
for (size_t i = 0; i < m_network.topDiff.size(); ++i) {
json_array_append(best, json_integer(m_network.topDiff[i]));
}
}

View file

@ -25,7 +25,7 @@
#define __APISTATE_H__
#include "api/Results.h"
#include "api/NetworkState.h"
#include "jansson.h"
@ -40,7 +40,7 @@ public:
const char *get(const char *url, size_t *size) const;
void tick(const Hashrate *hashrate);
void tick(const Results &results);
void tick(const NetworkState &results);
private:
const char *finalize(json_t *reply, size_t *size) const;
@ -58,7 +58,7 @@ private:
double m_totalHashrate[3];
int m_threads;
mutable char m_buf[4096];
Results m_results;
NetworkState m_network;
};
#endif /* __APISTATE_H__ */

View file

@ -25,11 +25,11 @@
#include <algorithm>
#include "api/Results.h"
#include "api/NetworkState.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) {
rejected++;

View file

@ -21,8 +21,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __RESULTS_H__
#define __RESULTS_H__
#ifndef __NETWORKSTATE_H__
#define __NETWORKSTATE_H__
#include <stdint.h>
@ -32,10 +32,10 @@
class SubmitResult;
class Results
class NetworkState
{
public:
inline Results() :
inline NetworkState() :
diff(0),
accepted(0),
rejected(0),
@ -51,4 +51,4 @@ public:
uint64_t total;
};
#endif /* __RESULTS_H__ */
#endif /* __NETWORKSTATE_H__ */