Browse Source

Check duplicate usernames within the same block

miguelfreitas
Miguel Freitas 11 years ago
parent
commit
ceddb2781b
  1. 9
      src/main.cpp

9
src/main.cpp

@ -1599,6 +1599,15 @@ bool CheckBlock(const CBlock& block, CValidationState& state, bool fCheckPOW, bo
if (uniqueTx.size() != block.vtx.size()) if (uniqueTx.size() != block.vtx.size())
return state.DoS(100, error("CheckBlock() : duplicate transaction")); return state.DoS(100, error("CheckBlock() : duplicate transaction"));
// Check duplicate usernames within the same block
set<uint256> uniqueUsers;
for (unsigned int i = 1; i < block.vtx.size(); i++) {
uniqueUsers.insert(block.vtx[i].GetUsernameHash());
}
if (uniqueUsers.size() != block.vtx.size()-1)
return state.DoS(100, error("CheckBlock() : duplicate username"));
// Check merkle root // Check merkle root
if (fCheckMerkleRoot && block.hashMerkleRoot != block.BuildMerkleTree()) if (fCheckMerkleRoot && block.hashMerkleRoot != block.BuildMerkleTree())
return state.DoS(100, error("CheckBlock() : hashMerkleRoot mismatch")); return state.DoS(100, error("CheckBlock() : hashMerkleRoot mismatch"));

Loading…
Cancel
Save