Built-in stratum server
This commit is contained in:
@@ -203,6 +203,7 @@ BITCOIN_CORE_H = \
|
|||||||
script/standard.h \
|
script/standard.h \
|
||||||
serialize.h \
|
serialize.h \
|
||||||
streams.h \
|
streams.h \
|
||||||
|
stratum.h \
|
||||||
support/allocators/secure.h \
|
support/allocators/secure.h \
|
||||||
support/allocators/zeroafterfree.h \
|
support/allocators/zeroafterfree.h \
|
||||||
support/cleanse.h \
|
support/cleanse.h \
|
||||||
@@ -315,6 +316,7 @@ libbitcoin_server_a_SOURCES = \
|
|||||||
rpc/server.cpp \
|
rpc/server.cpp \
|
||||||
script/serverchecker.cpp \
|
script/serverchecker.cpp \
|
||||||
script/sigcache.cpp \
|
script/sigcache.cpp \
|
||||||
|
stratum.cpp \
|
||||||
timedata.cpp \
|
timedata.cpp \
|
||||||
torcontrol.cpp \
|
torcontrol.cpp \
|
||||||
txdb.cpp \
|
txdb.cpp \
|
||||||
|
|||||||
@@ -40,6 +40,7 @@ public:
|
|||||||
|
|
||||||
const std::string& DataDir() const { return strDataDir; }
|
const std::string& DataDir() const { return strDataDir; }
|
||||||
int RPCPort() const { return nRPCPort; }
|
int RPCPort() const { return nRPCPort; }
|
||||||
|
int StratumPort() const { return (RPCPort() + 1000); }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
CBaseChainParams() {}
|
CBaseChainParams() {}
|
||||||
|
|||||||
14
src/init.cpp
14
src/init.cpp
@@ -36,6 +36,7 @@
|
|||||||
#include "httprpc.h"
|
#include "httprpc.h"
|
||||||
#include "key.h"
|
#include "key.h"
|
||||||
#include "notarizationdb.h"
|
#include "notarizationdb.h"
|
||||||
|
#include "stratum.h"
|
||||||
|
|
||||||
#ifdef ENABLE_MINING
|
#ifdef ENABLE_MINING
|
||||||
#include "key_io.h"
|
#include "key_io.h"
|
||||||
@@ -89,6 +90,7 @@
|
|||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
#include "hush_defs.h"
|
#include "hush_defs.h"
|
||||||
|
static const bool DEFAULT_STRATUM_ENABLE = false;
|
||||||
extern void ThreadSendAlert();
|
extern void ThreadSendAlert();
|
||||||
extern bool hush_dailysnapshot(int32_t height);
|
extern bool hush_dailysnapshot(int32_t height);
|
||||||
extern int32_t HUSH_LOADINGBLOCKS;
|
extern int32_t HUSH_LOADINGBLOCKS;
|
||||||
@@ -187,6 +189,7 @@ static boost::scoped_ptr<ECCVerifyHandle> globalVerifyHandle;
|
|||||||
|
|
||||||
void Interrupt(boost::thread_group& threadGroup)
|
void Interrupt(boost::thread_group& threadGroup)
|
||||||
{
|
{
|
||||||
|
InterruptStratumServer();
|
||||||
InterruptHTTPServer();
|
InterruptHTTPServer();
|
||||||
InterruptHTTPRPC();
|
InterruptHTTPRPC();
|
||||||
InterruptRPC();
|
InterruptRPC();
|
||||||
@@ -218,6 +221,7 @@ void Shutdown()
|
|||||||
StopHTTPRPC();
|
StopHTTPRPC();
|
||||||
StopREST();
|
StopREST();
|
||||||
StopRPC();
|
StopRPC();
|
||||||
|
StopStratumServer();
|
||||||
StopHTTPServer();
|
StopHTTPServer();
|
||||||
#ifdef ENABLE_WALLET
|
#ifdef ENABLE_WALLET
|
||||||
if (pwalletMain)
|
if (pwalletMain)
|
||||||
@@ -582,6 +586,13 @@ std::string HelpMessage(HelpMessageMode mode)
|
|||||||
strUsage += HelpMessageOpt("-metricsui", _("Set to 1 for a persistent metrics screen, 0 for sequential metrics output (default: 1 if running in a console, 0 otherwise)"));
|
strUsage += HelpMessageOpt("-metricsui", _("Set to 1 for a persistent metrics screen, 0 for sequential metrics output (default: 1 if running in a console, 0 otherwise)"));
|
||||||
strUsage += HelpMessageOpt("-metricsrefreshtime", strprintf(_("Number of seconds between metrics refreshes (default: %u if running in a console, %u otherwise)"), 1, 600));
|
strUsage += HelpMessageOpt("-metricsrefreshtime", strprintf(_("Number of seconds between metrics refreshes (default: %u if running in a console, %u otherwise)"), 1, 600));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
strUsage += HelpMessageGroup(_("Stratum server options:"));
|
||||||
|
strUsage += HelpMessageOpt("-stratum", _("Enable stratum server (default: off)"));
|
||||||
|
strUsage += HelpMessageOpt("-stratumbind=<addr>", _("Bind to given address to listen for Stratum work requests. Use [host]:port notation for IPv6. This option can be specified multiple times (default: bind to all interfaces)"));
|
||||||
|
strUsage += HelpMessageOpt("-stratumport=<port>", strprintf(_("Listen for Stratum work requests on <port> (default: %u or testnet: %u)"), BaseParams().StratumPort(), BaseParams().StratumPort()));
|
||||||
|
strUsage += HelpMessageOpt("-stratumallowip=<ip>", _("Allow Stratum work requests from specified source. Valid for <ip> are a single IP (e.g. 1.2.3.4), a network/netmask (e.g. 1.2.3.4/255.255.255.0) or a network/CIDR (e.g. 1.2.3.4/24). This option can be specified multiple times"));
|
||||||
|
|
||||||
strUsage += HelpMessageGroup(_("Hush Smart Chain options:"));
|
strUsage += HelpMessageGroup(_("Hush Smart Chain options:"));
|
||||||
strUsage += HelpMessageOpt("-ac_algo", _("Choose PoW mining algorithm, default is Equihash"));
|
strUsage += HelpMessageOpt("-ac_algo", _("Choose PoW mining algorithm, default is Equihash"));
|
||||||
strUsage += HelpMessageOpt("-ac_blocktime", _("Block time in seconds, default is 60"));
|
strUsage += HelpMessageOpt("-ac_blocktime", _("Block time in seconds, default is 60"));
|
||||||
@@ -941,10 +952,13 @@ static void ZC_LoadParams(
|
|||||||
|
|
||||||
bool AppInitServers(boost::thread_group& threadGroup)
|
bool AppInitServers(boost::thread_group& threadGroup)
|
||||||
{
|
{
|
||||||
|
fprintf(stderr,"%s: start\n",__func__);
|
||||||
RPCServer::OnStopped(&OnRPCStopped);
|
RPCServer::OnStopped(&OnRPCStopped);
|
||||||
RPCServer::OnPreCommand(&OnRPCPreCommand);
|
RPCServer::OnPreCommand(&OnRPCPreCommand);
|
||||||
if (!InitHTTPServer())
|
if (!InitHTTPServer())
|
||||||
return false;
|
return false;
|
||||||
|
if (GetBoolArg("-stratum", DEFAULT_STRATUM_ENABLE) && !InitStratumServer())
|
||||||
|
return false;
|
||||||
if (!StartRPC())
|
if (!StartRPC())
|
||||||
return false;
|
return false;
|
||||||
if (!StartHTTPRPC())
|
if (!StartHTTPRPC())
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
|
// Copyright (c) 2016-2021 The Hush developers
|
||||||
// Copyright (c) 2009-2016 The Bitcoin Core developers
|
// Copyright (c) 2009-2016 The Bitcoin Core developers
|
||||||
// Distributed under the GPLv3 software license, see the accompanying
|
// Distributed under the GPLv3 software license, see the accompanying
|
||||||
// file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html
|
// file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html
|
||||||
|
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
* Copyright © 2014-2019 The SuperNET Developers. *
|
* Copyright © 2014-2019 The SuperNET Developers. *
|
||||||
* *
|
* *
|
||||||
@@ -38,6 +38,9 @@ void RegisterRawTransactionRPCCommands(CRPCTable &tableRPC);
|
|||||||
/** Register test transaction RPC commands */
|
/** Register test transaction RPC commands */
|
||||||
void RegisterTesttransactionsRPCCommands(CRPCTable &tableRPC);
|
void RegisterTesttransactionsRPCCommands(CRPCTable &tableRPC);
|
||||||
|
|
||||||
|
/** Register stratum RPC commands */
|
||||||
|
void RegisterStratumRPCCommands(CRPCTable &tableRPC);
|
||||||
|
|
||||||
|
|
||||||
static inline void RegisterAllCoreRPCCommands(CRPCTable &tableRPC)
|
static inline void RegisterAllCoreRPCCommands(CRPCTable &tableRPC)
|
||||||
{
|
{
|
||||||
@@ -49,6 +52,7 @@ static inline void RegisterAllCoreRPCCommands(CRPCTable &tableRPC)
|
|||||||
#ifdef TESTMODE
|
#ifdef TESTMODE
|
||||||
RegisterTesttransactionsRPCCommands(tableRPC);
|
RegisterTesttransactionsRPCCommands(tableRPC);
|
||||||
#endif
|
#endif
|
||||||
|
RegisterStratumRPCCommands(tableRPC);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
2132
src/stratum.cpp
Normal file
2132
src/stratum.cpp
Normal file
File diff suppressed because it is too large
Load Diff
21
src/stratum.h
Normal file
21
src/stratum.h
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
// Copyright (c) 2021-2021 The Hush developers
|
||||||
|
// Copyright (c) 2020-2021 The Freicoin Developers
|
||||||
|
// This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
// License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||||
|
|
||||||
|
#ifndef HUSH_STRATUM_H
|
||||||
|
#define HUSH_STRATUM_H
|
||||||
|
|
||||||
|
/** Configure the stratum server. */
|
||||||
|
bool InitStratumServer();
|
||||||
|
|
||||||
|
/** Interrupt the stratum server connections. */
|
||||||
|
void InterruptStratumServer();
|
||||||
|
|
||||||
|
/** Cleanup stratum server network connections and free resources. */
|
||||||
|
void StopStratumServer();
|
||||||
|
|
||||||
|
#endif // HUSH_STRATUM_H
|
||||||
|
|
||||||
|
// End of File
|
||||||
Reference in New Issue
Block a user