Skip to content

Commit

Permalink
sserver feature "subres": Fix the issue that the calculation method o…
Browse files Browse the repository at this point in the history
…f submitIndex is inconsistent with BTCAgent.
  • Loading branch information
SwimmingTiger committed May 15, 2020
1 parent bf5234c commit 21167e2
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 10 deletions.
2 changes: 2 additions & 0 deletions src/StratumMessageDispatcher.h
Original file line number Diff line number Diff line change
Expand Up @@ -152,13 +152,15 @@ class StratumMessageAgentDispatcher : public StratumMessageDispatcher {
static void getSetDiffCommand(
std::map<uint8_t, std::vector<uint16_t>> &diffSessionIds,
std::string &exMessage);
inline uint16_t nextSubmitIndex() { return submitIndex_++; }

protected:
IStratumSession &session_;
std::unique_ptr<DiffController> diffController_;
uint64_t curDiff_ = 0;
std::map<uint16_t, std::unique_ptr<StratumMiner>> miners_;
bool enableSubmitResponse_ = false;
uint16_t submitIndex_ = 0;
};

#endif // #ifndef STRATUM_MESSAGE_DISPATCHER_H
32 changes: 24 additions & 8 deletions src/bitcoin/StratumMinerBitcoin.cc
Original file line number Diff line number Diff line change
Expand Up @@ -199,14 +199,30 @@ void StratumMinerBitcoin::handleExMessage_SubmitShare(
timestamp,
versionMask);

handleRequest_Submit(
std::to_string(submitIndex_++),
shortJobId,
fullExtraNonce2,
nonce,
timestamp,
versionMask,
0);
try {
auto dispatcher = dynamic_cast<StratumMessageAgentDispatcher *>(
&(session_.getDispatcher()));

handleRequest_Submit(
std::to_string(dispatcher->nextSubmitIndex()),
shortJobId,
fullExtraNonce2,
nonce,
timestamp,
versionMask,
0);
} catch (const std::bad_cast &ex) {
LOG(WARNING) << Strings::Format(
"[agent] submit before authorized, ignore! shortJobId: %02x, "
"sessionId: %08x, "
"exNonce2: %016x, nonce: %08x, time: %08x, versionMask: %08x",
shortJobId,
(uint32_t)sessionId,
fullExtraNonce2,
nonce,
timestamp,
versionMask);
}
#endif
}

Expand Down
2 changes: 0 additions & 2 deletions src/bitcoin/StratumMinerBitcoin.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,6 @@ class StratumMinerBitcoin : public StratumMinerBase<StratumTraitsBitcoin> {
uint32_t nTime,
uint32_t versionMask,
uint32_t extraGrandNonce1);

uint16_t submitIndex_ = 0;
};

#endif // #ifndef STRATUM_MINER_BITCOIN_H_

0 comments on commit 21167e2

Please sign in to comment.