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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue