Client refactoring.
This commit is contained in:
parent
d57b41c673
commit
be5d609856
6 changed files with 72 additions and 47 deletions
|
@ -5,7 +5,8 @@
|
|||
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
|
||||
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
|
||||
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||
* Copyright 2016-2018 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
* Copyright 2018-2019 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2019 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
@ -29,6 +30,7 @@
|
|||
|
||||
|
||||
#include "api/NetworkState.h"
|
||||
#include "base/tools/Chrono.h"
|
||||
#include "common/net/SubmitResult.h"
|
||||
|
||||
|
||||
|
@ -44,12 +46,6 @@ xmrig::NetworkState::NetworkState() :
|
|||
}
|
||||
|
||||
|
||||
int xmrig::NetworkState::connectionTime() const
|
||||
{
|
||||
return m_active ? (int)((uv_now(uv_default_loop()) - m_connectionTime) / 1000) : 0;
|
||||
}
|
||||
|
||||
|
||||
uint32_t xmrig::NetworkState::avgTime() const
|
||||
{
|
||||
if (m_latency.empty()) {
|
||||
|
@ -74,6 +70,12 @@ uint32_t xmrig::NetworkState::latency() const
|
|||
}
|
||||
|
||||
|
||||
uint64_t xmrig::NetworkState::connectionTime() const
|
||||
{
|
||||
return m_active ? ((Chrono::steadyMSecs() - m_connectionTime) / 1000) : 0;
|
||||
}
|
||||
|
||||
|
||||
void xmrig::NetworkState::add(const SubmitResult &result, const char *error)
|
||||
{
|
||||
if (error) {
|
||||
|
@ -99,7 +101,7 @@ void xmrig::NetworkState::setPool(const char *host, int port, const char *ip)
|
|||
snprintf(pool, sizeof(pool) - 1, "%s:%d", host, port);
|
||||
|
||||
m_active = true;
|
||||
m_connectionTime = uv_now(uv_default_loop());
|
||||
m_connectionTime = Chrono::steadyMSecs();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -41,9 +41,9 @@ class NetworkState
|
|||
public:
|
||||
NetworkState();
|
||||
|
||||
int connectionTime() const;
|
||||
uint32_t avgTime() const;
|
||||
uint32_t latency() const;
|
||||
uint64_t connectionTime() const;
|
||||
void add(const SubmitResult &result, const char *error);
|
||||
void setPool(const char *host, int port, const char *ip);
|
||||
void stop();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue