mirror of
https://github.com/GOSTSec/poolserver
synced 2025-01-14 08:47:53 +00:00
Improved duplicate share registry performance
This commit is contained in:
parent
af758bb37c
commit
a48cc66260
@ -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();
|
||||
|
@ -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…
Reference in New Issue
Block a user