Browse Source

Improved duplicate share registry performance

master
Intel 10 years ago
parent
commit
a48cc66260
  1. 10
      src/server/poolserver/Stratum/Client.cpp
  2. 9
      src/server/poolserver/Stratum/Job.h

10
src/server/poolserver/Stratum/Client.cpp

@ -166,9 +166,13 @@ namespace Stratum @@ -166,9 +166,13 @@ namespace Stratum
return;
}
ByteBuffer share;
share << extranonce2 << timebuf << noncebuf;
if (!job.SubmitShare(share.Binary())) {
// Pack two 32bit ints into 64bit
ByteBuffer sharebuf;
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());
DataMgr::Instance()->Push(Share(_ip, username, false, "Duplicate share", Util::Date(), job.diff));
_shareLimiter.LogBad();

9
src/server/poolserver/Stratum/Job.h

@ -16,18 +16,17 @@ namespace Stratum @@ -16,18 +16,17 @@ namespace Stratum
Bitcoin::BlockPtr block;
BinaryData coinbase1;
BinaryData coinbase2;
std::set<std::string> shares;
std::set<uint64> shares;
BigInt blockCriteria;
BigInt target;
// Submits share to a job
// 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<std::string>::iterator it = shares.find(sharestr);
std::set<uint64>::iterator it = shares.find(share);
if (it == shares.end()) {
shares.insert(sharestr);
shares.insert(share);
return true;
} else
return false;

Loading…
Cancel
Save