Browse Source

Add assertion and cast before sending reject code

This gets rid of a warning. Add an assertion to make sure that the
reject code is in the correct range for the network protocol
(if it is outside the range it must be a bug)
tags/v0.15.1
Wladimir J. van der Laan 5 years ago
parent
commit
5922b6774e
1 changed files with 2 additions and 1 deletions
  1. 2
    1
      src/main.cpp

+ 2
- 1
src/main.cpp View File

@@ -1343,7 +1343,8 @@ void static InvalidBlockFound(CBlockIndex *pindex, const CValidationState &state
if (state.IsInvalid(nDoS)) {
std::map<uint256, NodeId>::iterator it = mapBlockSource.find(pindex->GetBlockHash());
if (it != mapBlockSource.end() && State(it->second)) {
CBlockReject reject = {state.GetRejectCode(), state.GetRejectReason().substr(0, MAX_REJECT_MESSAGE_LENGTH), pindex->GetBlockHash()};
assert(state.GetRejectCode() < 0x100);
CBlockReject reject = {(unsigned char)state.GetRejectCode(), state.GetRejectReason().substr(0, MAX_REJECT_MESSAGE_LENGTH), pindex->GetBlockHash()};
State(it->second)->rejects.push_back(reject);
if (nDoS > 0)
Misbehaving(it->second, nDoS);

Loading…
Cancel
Save