1
0
mirror of https://github.com/GOSTSec/poolserver synced 2025-01-15 01:00:10 +00:00

Improved duplicate share registry performance

This commit is contained in:
Intel 2014-05-07 08:17:34 -04:00
parent af758bb37c
commit a48cc66260
2 changed files with 11 additions and 8 deletions

View File

@ -166,9 +166,13 @@ namespace Stratum
return; return;
} }
ByteBuffer share; // Pack two 32bit ints into 64bit
share << extranonce2 << timebuf << noncebuf; ByteBuffer sharebuf;
if (!job.SubmitShare(share.Binary())) { sharebuf << noncebuf << extranonce2;
uint64 share;
sharebuf >> share;
sLog.Debug(LOG_STRATUM, "Job::SubmitShare: Nonce: %s, Extranonse: %s, Share: %u", Util::BinToASCII(noncebuf.Binary()).c_str(), Util::BinToASCII(extranonce2).c_str(), share);
if (!job.SubmitShare(share)) {
sLog.Error(LOG_STRATUM, "%s: Duplicate share", username.c_str()); sLog.Error(LOG_STRATUM, "%s: Duplicate share", username.c_str());
DataMgr::Instance()->Push(Share(_ip, username, false, "Duplicate share", Util::Date(), job.diff)); DataMgr::Instance()->Push(Share(_ip, username, false, "Duplicate share", Util::Date(), job.diff));
_shareLimiter.LogBad(); _shareLimiter.LogBad();

View File

@ -16,18 +16,17 @@ namespace Stratum
Bitcoin::BlockPtr block; Bitcoin::BlockPtr block;
BinaryData coinbase1; BinaryData coinbase1;
BinaryData coinbase2; BinaryData coinbase2;
std::set<std::string> shares; std::set<uint64> shares;
BigInt blockCriteria; BigInt blockCriteria;
BigInt target; BigInt target;
// Submits share to a job // Submits share to a job
// Returns false if the same share already exists // Returns false if the same share already exists
bool SubmitShare(BinaryData share) bool SubmitShare(uint64 share)
{ {
std::string sharestr = Util::BinToASCII(Crypto::SHA256(share)); std::set<uint64>::iterator it = shares.find(share);
std::set<std::string>::iterator it = shares.find(sharestr);
if (it == shares.end()) { if (it == shares.end()) {
shares.insert(sharestr); shares.insert(share);
return true; return true;
} else } else
return false; return false;