diff --git a/src/ShareLogParser.h b/src/ShareLogParser.h index 3b06d9794..55dda82d3 100644 --- a/src/ShareLogParser.h +++ b/src/ShareLogParser.h @@ -107,7 +107,7 @@ class ShareLogParserT : public ShareLogParser { } void parseShareLog(const uint8_t *buf, size_t len); - void parseShare(const SHARE *share); + void parseShare(SHARE &share); void generateDailyData(shared_ptr> stats, const int32_t userId, const int64_t workerId, diff --git a/src/ShareLogParser.inl b/src/ShareLogParser.inl index 0a99c7eca..beae58e9d 100644 --- a/src/ShareLogParser.inl +++ b/src/ShareLogParser.inl @@ -162,22 +162,22 @@ void ShareLogParserT::parseShareLog(const uint8_t *buf, size_t len) { LOG(INFO) << "parse share from base message failed! " ; return; } - parseShare(&share); + parseShare(share); } template -void ShareLogParserT::parseShare(const SHARE *share) { - if (!share->isValid()) { - LOG(ERROR) << "invalid share: " << share->toString(); +void ShareLogParserT::parseShare(SHARE &share) { + if (!share.isValid()) { + LOG(ERROR) << "invalid share: " << share.toString(); return; } - if (dupShareChecker_ && !dupShareChecker_->addShare(*share)) { - LOG(INFO) << "duplicate share attack: " << share->toString(); - return; + if (dupShareChecker_ && !dupShareChecker_->addShare(share)) { + LOG(INFO) << "duplicate share attack: " << share.toString(); + share.set_status(StratumStatus::DUPLICATE_SHARE); } - WorkerKey wkey(share->userid(), share->workerhashid()); - WorkerKey ukey(share->userid(), 0); + WorkerKey wkey(share.userid(), share.workerhashid()); + WorkerKey ukey(share.userid(), 0); WorkerKey pkey(0, 0); pthread_rwlock_wrlock(&rwlock_); @@ -189,10 +189,10 @@ void ShareLogParserT::parseShare(const SHARE *share) { } pthread_rwlock_unlock(&rwlock_); - const uint32_t hourIdx = getHourIdx(share->timestamp()); - workersStats_[wkey]->processShare(hourIdx, *share); - workersStats_[ukey]->processShare(hourIdx, *share); - workersStats_[pkey]->processShare(hourIdx, *share); + const uint32_t hourIdx = getHourIdx(share.timestamp()); + workersStats_[wkey]->processShare(hourIdx, share); + workersStats_[ukey]->processShare(hourIdx, share); + workersStats_[pkey]->processShare(hourIdx, share); } template diff --git a/src/StatsHttpd.inl b/src/StatsHttpd.inl index 33e7f5d38..311cbc5df 100644 --- a/src/StatsHttpd.inl +++ b/src/StatsHttpd.inl @@ -1004,15 +1004,13 @@ void StatsServerT::consumeShareLog(rd_kafka_message_t *rkmessage) { return; } - - if (!share.isValid()) { LOG(ERROR) << "invalid share: " << share.toString(); return; } if (dupShareChecker_ && !dupShareChecker_->addShare(share)) { LOG(INFO) << "duplicate share attack: " << share.toString(); - return; + share.set_status(StratumStatus::DUPLICATE_SHARE); } processShare(share);