Create network strategies in Pools class.
This commit is contained in:
parent
ee4f6e28f0
commit
3a0fdcac6f
8 changed files with 71 additions and 39 deletions
|
@ -25,6 +25,8 @@
|
|||
|
||||
#include "base/net/Pools.h"
|
||||
#include "common/log/Log.h"
|
||||
#include "common/net/strategies/FailoverStrategy.h"
|
||||
#include "common/net/strategies/SinglePoolStrategy.h"
|
||||
#include "rapidjson/document.h"
|
||||
|
||||
|
||||
|
@ -68,6 +70,27 @@ bool xmrig::Pools::setUrl(const char *url)
|
|||
}
|
||||
|
||||
|
||||
xmrig::IStrategy *xmrig::Pools::createStrategy(IStrategyListener *listener) const
|
||||
{
|
||||
if (active() == 1) {
|
||||
for (const Pool &pool : m_data) {
|
||||
if (pool.isEnabled()) {
|
||||
return new SinglePoolStrategy(pool, retryPause(), retries(), listener);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
FailoverStrategy *strategy = new FailoverStrategy(retryPause(), retries(), listener);
|
||||
for (const Pool &pool : m_data) {
|
||||
if (pool.isEnabled()) {
|
||||
strategy->add(pool);
|
||||
}
|
||||
}
|
||||
|
||||
return strategy;
|
||||
}
|
||||
|
||||
|
||||
rapidjson::Value xmrig::Pools::toJSON(rapidjson::Document &doc) const
|
||||
{
|
||||
using namespace rapidjson;
|
||||
|
|
|
@ -35,6 +35,10 @@
|
|||
namespace xmrig {
|
||||
|
||||
|
||||
class IStrategy;
|
||||
class IStrategyListener;
|
||||
|
||||
|
||||
class Pools
|
||||
{
|
||||
public:
|
||||
|
@ -56,6 +60,7 @@ public:
|
|||
inline void setVariant(int variant) { current().algorithm().parseVariant(variant); }
|
||||
|
||||
bool setUrl(const char *url);
|
||||
IStrategy *createStrategy(IStrategyListener *listener) const;
|
||||
rapidjson::Value toJSON(rapidjson::Document &doc) const;
|
||||
size_t active() const;
|
||||
void adjust(const Algorithm &algorithm);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue