[Node] Only allow 1 node with the same public key

This commit is contained in:
momo5502 2017-01-14 01:13:22 +01:00
parent f68baa8303
commit e34958d478
2 changed files with 14 additions and 0 deletions

View File

@ -484,6 +484,15 @@ namespace Components
return;
}
for (auto& node : Node::Nodes)
{
if (node.publicKey == entry->publicKey)
{
entry->lastTime = Game::Sys_Milliseconds();
entry->state = Node::STATE_INVALID;
}
}
// Mark as registered
entry->lastTime = Game::Sys_Milliseconds();
entry->state = Node::STATE_VALID;

View File

@ -227,6 +227,11 @@ namespace Utils
ZeroMemory(this->getKeyPtr(), sizeof(*this->getKeyPtr()));
}
bool operator==(Key& key)
{
return (this->isValid() && key.isValid() && this->serialize(PK_PUBLIC) == key.serialize(PK_PUBLIC));
}
private:
std::shared_ptr<ecc_key> keyStorage;
};