full implementation of peer test

This commit is contained in:
orignal 2015-02-25 21:56:51 -05:00
parent 34e31f3d78
commit 51aea367c3
4 changed files with 90 additions and 40 deletions

22
SSU.cpp
View file

@ -463,12 +463,28 @@ namespace transport
}
}
void SSUServer::NewPeerTest (uint32_t nonce)
void SSUServer::NewPeerTest (uint32_t nonce, PeerTestParticipant role)
{
m_PeerTests[nonce] = i2p::util::GetMillisecondsSinceEpoch ();
m_PeerTests[nonce] = { i2p::util::GetMillisecondsSinceEpoch (), role };
}
void SSUServer::PeerTestComplete (uint32_t nonce)
PeerTestParticipant SSUServer::GetPeerTestParticipant (uint32_t nonce)
{
auto it = m_PeerTests.find (nonce);
if (it != m_PeerTests.end ())
return it->second.role;
else
return ePeerTestParticipantUnknown;
}
void SSUServer::UpdatePeerTest (uint32_t nonce, PeerTestParticipant role)
{
auto it = m_PeerTests.find (nonce);
if (it != m_PeerTests.end ())
it->second.role = role;
}
void SSUServer::RemovePeerTest (uint32_t nonce)
{
m_PeerTests.erase (nonce);
}