Added results statistics to API.
This commit is contained in:
parent
1651b041de
commit
9e9cddedc5
21 changed files with 265 additions and 57 deletions
|
@ -30,12 +30,14 @@
|
|||
#include <time.h>
|
||||
|
||||
|
||||
#include "api/Api.h"
|
||||
#include "log/Log.h"
|
||||
#include "net/Client.h"
|
||||
#include "net/Network.h"
|
||||
#include "net/strategies/DonateStrategy.h"
|
||||
#include "net/strategies/FailoverStrategy.h"
|
||||
#include "net/strategies/SinglePoolStrategy.h"
|
||||
#include "net/SubmitResult.h"
|
||||
#include "net/Url.h"
|
||||
#include "Options.h"
|
||||
#include "Platform.h"
|
||||
|
@ -44,9 +46,7 @@
|
|||
|
||||
Network::Network(const Options *options) :
|
||||
m_options(options),
|
||||
m_donate(nullptr),
|
||||
m_accepted(0),
|
||||
m_rejected(0)
|
||||
m_donate(nullptr)
|
||||
{
|
||||
srand(time(0) ^ (uintptr_t) this);
|
||||
|
||||
|
@ -139,21 +139,19 @@ void Network::onPause(IStrategy *strategy)
|
|||
}
|
||||
|
||||
|
||||
void Network::onResultAccepted(Client *client, int64_t seq, uint32_t diff, uint64_t ms, const char *error)
|
||||
void Network::onResultAccepted(Client *client, const SubmitResult &result, const char *error)
|
||||
{
|
||||
if (error) {
|
||||
m_rejected++;
|
||||
m_results.add(result, 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)"
|
||||
: "rejected (%" PRId64 "/%" PRId64 ") diff %u \"%s\" (%" PRIu64 " ms)",
|
||||
m_accepted, m_rejected, diff, error, ms);
|
||||
m_results.accepted, m_results.rejected, result.diff, error, result.elapsed);
|
||||
}
|
||||
else {
|
||||
m_accepted++;
|
||||
|
||||
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)",
|
||||
m_accepted, m_rejected, diff, ms);
|
||||
m_results.accepted, m_results.rejected, result.diff, result.elapsed);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -162,12 +160,12 @@ void Network::setJob(Client *client, const Job &job)
|
|||
{
|
||||
if (m_options->colors()) {
|
||||
LOG_INFO("\x1B[01;35mnew job\x1B[0m from \x1B[01;37m%s:%d\x1B[0m diff \x1B[01;37m%d", client->host(), client->port(), job.diff());
|
||||
|
||||
}
|
||||
else {
|
||||
LOG_INFO("new job from %s:%d diff %d", client->host(), client->port(), job.diff());
|
||||
}
|
||||
|
||||
m_results.diff = job.diff();
|
||||
Workers::setJob(job);
|
||||
}
|
||||
|
||||
|
@ -181,6 +179,8 @@ void Network::tick()
|
|||
if (m_donate) {
|
||||
m_donate->tick(now);
|
||||
}
|
||||
|
||||
Api::tick(m_results);
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue