Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 20c3973504 | |||
| 16b74edc51 | |||
| d611056b1c | |||
| ecc33cfebb | |||
| 0ae2af0bb8 | |||
| bdd34c5f56 |
+25
-19
@@ -1009,29 +1009,32 @@ void StratumServer::on_share_found(uv_work_t* req)
|
||||
|
||||
share->m_score = GOOD_SHARE_POINTS;
|
||||
|
||||
const double diff = sidechain_difficulty.to_double();
|
||||
time_t prev_time;
|
||||
const time_t cur_time = time(nullptr);
|
||||
{
|
||||
WriteLock lock(server->m_hashrateDataLock);
|
||||
if (share->m_highEnoughDifficulty) {
|
||||
const double diff = sidechain_difficulty.to_double();
|
||||
time_t prev_time;
|
||||
const time_t cur_time = time(nullptr);
|
||||
{
|
||||
WriteLock lock(server->m_hashrateDataLock);
|
||||
|
||||
const uint64_t n = server->m_cumulativeHashes + hashes;
|
||||
share->m_effort = static_cast<double>(n - server->m_cumulativeHashesAtLastShare) * 100.0 / diff;
|
||||
server->m_cumulativeHashesAtLastShare = n;
|
||||
const uint64_t n = server->m_cumulativeHashes + hashes;
|
||||
share->m_effort = static_cast<double>(n - server->m_cumulativeHashesAtLastShare) * 100.0 / diff;
|
||||
server->m_cumulativeHashesAtLastShare = n;
|
||||
|
||||
server->m_cumulativeFoundSharesDiff += diff;
|
||||
++server->m_totalFoundSidechainShares;
|
||||
server->m_cumulativeFoundSharesDiff += diff;
|
||||
++server->m_totalFoundSidechainShares;
|
||||
|
||||
prev_time = server->m_lastSidechainShareFoundTime;
|
||||
server->m_lastSidechainShareFoundTime = cur_time;
|
||||
}
|
||||
if (share->m_highEnoughDifficulty && !pool->submit_sidechain_block(share->m_templateId, share->m_nonce, share->m_extraNonce)) {
|
||||
WriteLock lock(server->m_hashrateDataLock);
|
||||
prev_time = server->m_lastSidechainShareFoundTime;
|
||||
server->m_lastSidechainShareFoundTime = cur_time;
|
||||
}
|
||||
|
||||
if (server->m_totalFoundSidechainShares > 0) {
|
||||
--server->m_totalFoundSidechainShares;
|
||||
++server->m_totalFailedSidechainShares;
|
||||
server->m_lastSidechainShareFoundTime = prev_time;
|
||||
if (!pool->submit_sidechain_block(share->m_templateId, share->m_nonce, share->m_extraNonce)) {
|
||||
WriteLock lock(server->m_hashrateDataLock);
|
||||
|
||||
if (server->m_totalFoundSidechainShares > 0) {
|
||||
--server->m_totalFoundSidechainShares;
|
||||
++server->m_totalFailedSidechainShares;
|
||||
server->m_lastSidechainShareFoundTime = prev_time;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1078,6 +1081,9 @@ void StratumServer::on_after_share_found(uv_work_t* req, int /*status*/)
|
||||
const char* reason = (k < array_size(reason_list)) ? reason_list[k] : "unknown";
|
||||
LOGWARN(0, "INVALID SHARE: mainchain height " << share->m_mainchainHeight << ", sidechain height " << share->m_sidechainHeight << ", diff " << share->m_sidechainDifficulty << ", client " << static_cast<char*>(share->m_clientAddrString) << (*s ? ", user " : "") << s << ", reason: " << reason);
|
||||
}
|
||||
}
|
||||
|
||||
if (share->m_highEnoughDifficulty || server->m_enableFullValidation) {
|
||||
BACKGROUND_JOB_STOP(StratumServer::on_share_found);
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -36,7 +36,7 @@ namespace p2pool {
|
||||
|
||||
#define P2POOL_VERSION_MAJOR 4
|
||||
#define P2POOL_VERSION_MINOR 10
|
||||
#define P2POOL_VERSION_PATCH 0
|
||||
#define P2POOL_VERSION_PATCH 1
|
||||
|
||||
constexpr uint32_t P2POOL_VERSION = (P2POOL_VERSION_MAJOR << 16) | (P2POOL_VERSION_MINOR << 8) | P2POOL_VERSION_PATCH;
|
||||
|
||||
|
||||
+15
-6
@@ -338,9 +338,14 @@ static std::vector<uint8_t> construct_monero_block_blob(rapidjson::Value* value)
|
||||
|
||||
auto arr = outputs->value.GetArray();
|
||||
|
||||
if (arr.Empty()) {
|
||||
LOGWARN(3, "construct_monero_block_blob: outputs array is empty");
|
||||
return empty_blob;
|
||||
}
|
||||
|
||||
writeVarint(arr.Size(), blob);
|
||||
|
||||
for (rapidjson::Value* i = arr.begin(); i != arr.end(); ++i) {
|
||||
for (auto i = arr.begin(); i != arr.end(); ++i) {
|
||||
auto amount = i->FindMember("amount");
|
||||
if ((amount == i->MemberEnd()) || !amount->value.IsUint64()) {
|
||||
LOGWARN(3, "construct_monero_block_blob: amount not found or is not UInt64");
|
||||
@@ -385,7 +390,7 @@ static std::vector<uint8_t> construct_monero_block_blob(rapidjson::Value* value)
|
||||
}
|
||||
|
||||
std::vector<uint8_t> t;
|
||||
if (!from_hex(extra.c_str(), extra.length(), t) || t.empty()) {
|
||||
if (!from_hex(extra.c_str(), extra.length(), t) || (t.size() < HASH_SIZE + 1)) {
|
||||
LOGWARN(3, "construct_monero_block_blob: invalid extra " << extra);
|
||||
return empty_blob;
|
||||
}
|
||||
@@ -401,8 +406,12 @@ static std::vector<uint8_t> construct_monero_block_blob(rapidjson::Value* value)
|
||||
|
||||
writeVarint(arr2.Size(), blob);
|
||||
|
||||
for (rapidjson::Value* i = arr2.begin(); i != arr2.end(); ++i) {
|
||||
if (!i->IsString() || !from_hex(i->GetString(), i->GetStringLength(), h)) {
|
||||
for (auto i = arr2.begin(); i != arr2.end(); ++i) {
|
||||
if (!i->IsString()) {
|
||||
LOGWARN(3, "construct_monero_block_blob: tx_hash is not a string");
|
||||
return empty_blob;
|
||||
}
|
||||
if (!from_hex(i->GetString(), i->GetStringLength(), h)) {
|
||||
LOGWARN(3, "construct_monero_block_blob: invalid tx_hash " << i->GetString());
|
||||
return empty_blob;
|
||||
}
|
||||
@@ -506,7 +515,7 @@ void ZMQReader::parse(char* data, size_t size)
|
||||
}
|
||||
else if (strcmp(data, "json-full-chain_main") == 0) {
|
||||
if (!doc.IsArray()) {
|
||||
LOGWARN(1, "json-full-chain_main is not an object, skipping it");
|
||||
LOGWARN(1, "json-full-chain_main is not an array, skipping it");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -515,7 +524,7 @@ void ZMQReader::parse(char* data, size_t size)
|
||||
std::vector<std::vector<uint8_t>> blobs;
|
||||
blobs.reserve(arr.Size());
|
||||
|
||||
for (Value* i = arr.begin(); i != arr.end(); ++i) {
|
||||
for (auto i = arr.begin(); i != arr.end(); ++i) {
|
||||
blobs.emplace_back(construct_monero_block_blob(i));
|
||||
|
||||
if (!PARSE(*i, m_chainmainData, timestamp)) {
|
||||
|
||||
Reference in New Issue
Block a user