Add some stratum spices
This commit is contained in:
@@ -512,7 +512,7 @@ std::string HelpMessage(HelpMessageMode mode)
|
|||||||
strUsage += HelpMessageOpt("-stopafterblockimport", strprintf("Stop running after importing blocks from disk (default: %u)", 0));
|
strUsage += HelpMessageOpt("-stopafterblockimport", strprintf("Stop running after importing blocks from disk (default: %u)", 0));
|
||||||
strUsage += HelpMessageOpt("-nuparams=hexBranchId:activationHeight", "Use given activation height for specified network upgrade (regtest-only)");
|
strUsage += HelpMessageOpt("-nuparams=hexBranchId:activationHeight", "Use given activation height for specified network upgrade (regtest-only)");
|
||||||
}
|
}
|
||||||
string debugCategories = "addrman, alert, bench, coindb, db, deletetx, estimatefee, http, libevent, lock, mempool, net, tls, partitioncheck, pow, proxy, prune, rand, reindex, rpc, selectcoins, tor, zmq, zrpc, zrpcunsafe (implies zrpc)"; // Don't translate these
|
string debugCategories = "addrman, alert, bench, coindb, db, deletetx, estimatefee, http, libevent, lock, mempool, net, tls, partitioncheck, pow, proxy, prune, rand, reindex, rpc, selectcoins, stratum, tor, zmq, zrpc, zrpcunsafe (implies zrpc)"; // Don't translate these
|
||||||
strUsage += HelpMessageOpt("-debug=<category>", strprintf(_("Output debugging information (default: %u, supplying <category> is optional)"), 0) + ". " +
|
strUsage += HelpMessageOpt("-debug=<category>", strprintf(_("Output debugging information (default: %u, supplying <category> is optional)"), 0) + ". " +
|
||||||
_("If <category> is not supplied or if <category> = 1, output all debugging information.") + " " + _("<category> can be:") + " " + debugCategories + ".");
|
_("If <category> is not supplied or if <category> = 1, output all debugging information.") + " " + _("<category> can be:") + " " + debugCategories + ".");
|
||||||
strUsage += HelpMessageOpt("-experimentalfeatures", _("Enable use of experimental features"));
|
strUsage += HelpMessageOpt("-experimentalfeatures", _("Enable use of experimental features"));
|
||||||
|
|||||||
@@ -312,10 +312,10 @@ namespace ccminer {
|
|||||||
/* compute nbits to get the network diff */
|
/* compute nbits to get the network diff */
|
||||||
double equi_network_diff(uint32_t nbits)
|
double equi_network_diff(uint32_t nbits)
|
||||||
{
|
{
|
||||||
//KMD bits: "1e 015971",
|
//HUSH bits: "1e 015971",
|
||||||
//KMD target: "00 00 015971000000000000000000000000000000000000000000000000000000",
|
//HUSH target: "00 00 015971000000000000000000000000000000000000000000000000000000",
|
||||||
//KMD bits: "1d 686aaf",
|
//HUSH bits: "1d 686aaf",
|
||||||
//KMD target: "00 0000 686aaf0000000000000000000000000000000000000000000000000000",
|
//HUSH target: "00 0000 686aaf0000000000000000000000000000000000000000000000000000",
|
||||||
// uint32_t nbits = work->data[26];
|
// uint32_t nbits = work->data[26];
|
||||||
|
|
||||||
uint32_t bits = (nbits & 0xffffff);
|
uint32_t bits = (nbits & 0xffffff);
|
||||||
@@ -1051,11 +1051,11 @@ bool SubmitBlock(StratumClient& client, const uint256& job_id, const StratumWork
|
|||||||
// std::cerr << strprintf("%f ms - %" PRIu64 "", elapsed.count(), shares_accepted_since_last) << std::endl;
|
// std::cerr << strprintf("%f ms - %" PRIu64 "", elapsed.count(), shares_accepted_since_last) << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool fDisplayDiffKMD = true; // otherwise it will display ccminer diff
|
bool fDisplayDiffHUSH = true; // otherwise it will display ccminer diff
|
||||||
|
|
||||||
std::cerr << DateTimeStrPrecise() <<
|
std::cerr << DateTimeStrPrecise() <<
|
||||||
strprintf("%saccepted: %" PRIu64 "/%" PRIu64 "%s ", ColorTypeNames[cl_WHT], counter_TotalBlocks, counter_TotalShares, ColorTypeNames[cl_N] );
|
strprintf("%saccepted: %" PRIu64 "/%" PRIu64 "%s ", ColorTypeNames[cl_WHT], counter_TotalBlocks, counter_TotalShares, ColorTypeNames[cl_N] );
|
||||||
if (fDisplayDiffKMD) {
|
if (fDisplayDiffHUSH) {
|
||||||
/* hushd diff display */
|
/* hushd diff display */
|
||||||
std::cerr << strprintf("%slocal %g%s ", "\x1B[90m", hush_local_diff, ColorTypeNames[cl_N]) <<
|
std::cerr << strprintf("%slocal %g%s ", "\x1B[90m", hush_local_diff, ColorTypeNames[cl_N]) <<
|
||||||
strprintf("%s(diff %g, target %g) %s ", ColorTypeNames[cl_WHT], hush_real_diff, hush_target_diff, ColorTypeNames[cl_N]);
|
strprintf("%s(diff %g, target %g) %s ", ColorTypeNames[cl_WHT], hush_real_diff, hush_target_diff, ColorTypeNames[cl_N]);
|
||||||
@@ -1205,7 +1205,7 @@ UniValue stratum_mining_subscribe(StratumClient& client, const UniValue& params)
|
|||||||
ret.push_back(NullUniValue);
|
ret.push_back(NullUniValue);
|
||||||
ret.push_back(sExtraNonce1);
|
ret.push_back(sExtraNonce1);
|
||||||
|
|
||||||
// On mining.subscribe we don't need ti send anything else, we will send
|
// On mining.subscribe we don't need to send anything else, we will send
|
||||||
// mining.set_target and mining.notify bit later, inside GetWorkUnit.
|
// mining.set_target and mining.notify bit later, inside GetWorkUnit.
|
||||||
// Scheme is the following:
|
// Scheme is the following:
|
||||||
// 1. stratum_read_cb(bufferevent * bev, void * ctx)
|
// 1. stratum_read_cb(bufferevent * bev, void * ctx)
|
||||||
@@ -1417,7 +1417,6 @@ static void stratum_read_cb(bufferevent *bev, void *ctx)
|
|||||||
free(cstr);
|
free(cstr);
|
||||||
LogPrint("stratum", "Received stratum request from %s : %s\n", client.GetPeer().ToString(), line);
|
LogPrint("stratum", "Received stratum request from %s : %s\n", client.GetPeer().ToString(), line);
|
||||||
|
|
||||||
//JSONRPCRequest jreq;
|
|
||||||
JSONRequest jreq;
|
JSONRequest jreq;
|
||||||
|
|
||||||
std::string reply;
|
std::string reply;
|
||||||
@@ -1426,11 +1425,11 @@ static void stratum_read_cb(bufferevent *bev, void *ctx)
|
|||||||
UniValue valRequest;
|
UniValue valRequest;
|
||||||
if (!valRequest.read(line)) {
|
if (!valRequest.read(line)) {
|
||||||
// Not JSON; is this even a stratum miner?
|
// Not JSON; is this even a stratum miner?
|
||||||
throw JSONRPCError(RPC_PARSE_ERROR, "Parse error");
|
throw JSONRPCError(RPC_PARSE_ERROR, strprintf("Invalid JSON, Parse error on: %s",line) );
|
||||||
}
|
}
|
||||||
if (!valRequest.isObject()) {
|
if (!valRequest.isObject()) {
|
||||||
// Not a JSON object; don't know what to do.
|
// Not a JSON object; don't know what to do.
|
||||||
throw JSONRPCError(RPC_PARSE_ERROR, "Top-level object parse error");
|
throw JSONRPCError(RPC_PARSE_ERROR, "Not a JSON object");
|
||||||
}
|
}
|
||||||
if (valRequest.exists("result")) {
|
if (valRequest.exists("result")) {
|
||||||
// JSON-RPC reply. Ignore.
|
// JSON-RPC reply. Ignore.
|
||||||
@@ -1809,7 +1808,10 @@ void SendKeepAlivePackets()
|
|||||||
bool InitStratumServer()
|
bool InitStratumServer()
|
||||||
{
|
{
|
||||||
LOCK(cs_stratum);
|
LOCK(cs_stratum);
|
||||||
fprintf(stderr,"%s: Starting built-in stratum server\n",__func__);
|
|
||||||
|
int stratumPort = BaseParams().StratumPort();
|
||||||
|
int defaultPort = GetArg("-stratumport", stratumPort);
|
||||||
|
fprintf(stderr,"%s: Starting built-in stratum server on port %d\n",__func__, defaultPort );
|
||||||
|
|
||||||
|
|
||||||
if (!InitStratumAllowList(stratum_allow_subnets)) {
|
if (!InitStratumAllowList(stratum_allow_subnets)) {
|
||||||
@@ -1834,14 +1836,12 @@ bool InitStratumServer()
|
|||||||
LogPrint("stratum", "Initialized stratum server\n");
|
LogPrint("stratum", "Initialized stratum server\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
stratum_method_dispatch["mining.subscribe"] = stratum_mining_subscribe;
|
stratum_method_dispatch["mining.subscribe"] = stratum_mining_subscribe;
|
||||||
stratum_method_dispatch["mining.authorize"] = stratum_mining_authorize;
|
stratum_method_dispatch["mining.authorize"] = stratum_mining_authorize;
|
||||||
stratum_method_dispatch["mining.configure"] = stratum_mining_configure;
|
stratum_method_dispatch["mining.configure"] = stratum_mining_configure;
|
||||||
stratum_method_dispatch["mining.submit"] = stratum_mining_submit;
|
stratum_method_dispatch["mining.submit"] = stratum_mining_submit;
|
||||||
stratum_method_dispatch["mining.extranonce.subscribe"] =
|
stratum_method_dispatch["mining.extranonce.subscribe"] = stratum_mining_extranonce_subscribe;
|
||||||
stratum_mining_extranonce_subscribe;
|
stratum_method_dispatch["mining.multi_version"] = stratum_mining_multi_version;
|
||||||
stratum_method_dispatch["mining.multi_version"] =
|
|
||||||
stratum_mining_multi_version;
|
|
||||||
|
|
||||||
|
|
||||||
// Start thread to wait for block notifications and send updated
|
// Start thread to wait for block notifications and send updated
|
||||||
@@ -1902,7 +1902,6 @@ UniValue rpc_stratum_updatework(const UniValue& params, bool fHelp, const CPubKe
|
|||||||
uint64_t skipped = 0;
|
uint64_t skipped = 0;
|
||||||
|
|
||||||
// send updated work to miners
|
// send updated work to miners
|
||||||
|
|
||||||
// if (cs_stratum.try_lock())
|
// if (cs_stratum.try_lock())
|
||||||
{
|
{
|
||||||
LOCK(cs_stratum);
|
LOCK(cs_stratum);
|
||||||
@@ -1935,6 +1934,7 @@ UniValue rpc_stratum_updatework(const UniValue& params, bool fHelp, const CPubKe
|
|||||||
|
|
||||||
// Ignore clients that aren't authorized yet.
|
// Ignore clients that aren't authorized yet.
|
||||||
if (!client.m_authorized && client.m_aux_addr.empty()) {
|
if (!client.m_authorized && client.m_aux_addr.empty()) {
|
||||||
|
fprintf(stderr,"%s: Ignoring unauthorized client\n", __func__);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user