convert RSDHT_PEERDHT_ to enum class

This commit is contained in:
sehraf 2020-02-19 19:35:34 +01:00
parent 1b1b09217a
commit 8d0a352b53
No known key found for this signature in database
GPG key ID: DF09F6EAE356B2C6
6 changed files with 36 additions and 33 deletions

View file

@ -51,7 +51,7 @@ class DhtPeerDetails
RsPeerId mRsId;
/* direct from the DHT! */
uint32_t mDhtState; // One of RSDHT_PEERDHT_[...]
RsDhtPeerDht mDhtState;
rstime_t mDhtUpdateTS;
/* internal state */

View file

@ -222,26 +222,26 @@ int p3BitDht::PeerCallback(const bdId *id, uint32_t status)
switch(status)
{
default:
dpd->mDhtState = RSDHT_PEERDHT_NOT_ACTIVE;
dpd->mDhtState = RsDhtPeerDht::NOT_ACTIVE;
break;
case BITDHT_MGR_QUERY_FAILURE:
dpd->mDhtState = RSDHT_PEERDHT_FAILURE;
dpd->mDhtState = RsDhtPeerDht::FAILURE;
break;
case BITDHT_MGR_QUERY_PEER_OFFLINE:
dpd->mDhtState = RSDHT_PEERDHT_OFFLINE;
dpd->mDhtState = RsDhtPeerDht::OFFLINE;
break;
case BITDHT_MGR_QUERY_PEER_UNREACHABLE:
dpd->mDhtState = RSDHT_PEERDHT_UNREACHABLE;
dpd->mDhtState = RsDhtPeerDht::UNREACHABLE;
dpd->mDhtId = *id; // set the IP:Port of the unreachable peer.
UnreachablePeerCallback_locked(id, status, dpd);
break;
case BITDHT_MGR_QUERY_PEER_ONLINE:
dpd->mDhtState = RSDHT_PEERDHT_ONLINE;
dpd->mDhtState = RsDhtPeerDht::ONLINE;
dpd->mDhtId = *id; // set the IP:Port of the Online peer.
OnlinePeerCallback_locked(id, status, dpd);
@ -1749,7 +1749,7 @@ int p3BitDht::checkConnectionAllowed(const bdId *peerId, int mode)
/* flag as failed */
it->second.mDhtId = *peerId;
it->second.mDhtState = RSDHT_PEERDHT_NOT_ACTIVE;
it->second.mDhtState = RsDhtPeerDht::NOT_ACTIVE;
it->second.mDhtUpdateTS = now;
it->second.mPeerType = RsDhtPeerType::OTHER;

View file

@ -76,7 +76,7 @@ bool p3BitDht::findPeer(const RsPeerId& pid)
}
/* new entry... what do we need to set? */
dpd->mDhtState = RSDHT_PEERDHT_SEARCHING;
dpd->mDhtState = RsDhtPeerDht::SEARCHING;
#ifdef DEBUG_BITDHT
std::cerr << "p3BitDht::findPeer() Installed new DhtPeer with pid => NodeId: ";
@ -93,7 +93,7 @@ bool p3BitDht::findPeer(const RsPeerId& pid)
std::cerr << std::endl;
#endif
if (dpd->mDhtState != RSDHT_PEERDHT_NOT_ACTIVE)
if (dpd->mDhtState != RsDhtPeerDht::NOT_ACTIVE)
{
#ifdef DEBUG_BITDHT
std::cerr << "p3BitDht::findPeer() WARNING DhtState is Already Active!";
@ -104,7 +104,7 @@ bool p3BitDht::findPeer(const RsPeerId& pid)
else
{
/* flag as searching */
dpd->mDhtState = RSDHT_PEERDHT_SEARCHING;
dpd->mDhtState = RsDhtPeerDht::SEARCHING;
#ifdef DEBUG_BITDHT
std::cerr << "p3BitDht::findPeer() Marking Old Peer as SEARCHING";
std::cerr << std::endl;
@ -156,7 +156,7 @@ bool p3BitDht::dropPeer(const RsPeerId& pid)
}
/* flag as searching */
dpd->mDhtState = RSDHT_PEERDHT_NOT_ACTIVE;
dpd->mDhtState = RsDhtPeerDht::NOT_ACTIVE;
nid = dpd->mDhtId.id;
@ -418,7 +418,7 @@ DhtPeerDetails *p3BitDht::addInternalPeer_locked(const RsPeerId& pid, RsDhtPeerT
newdpd.mDhtId.id = id;
newdpd.mRsId = pid;
newdpd.mDhtState = RSDHT_PEERDHT_NOT_ACTIVE;
newdpd.mDhtState = RsDhtPeerDht::NOT_ACTIVE;
newdpd.mPeerType = RsDhtPeerType::ANY;
mPeers[id] = newdpd;
@ -717,9 +717,9 @@ int p3BitDht::calculateNodeId(const RsPeerId& pid, bdNodeId *id)
DhtPeerDetails::DhtPeerDetails()
{
mDhtState = RSDHT_PEERDHT_NOT_ACTIVE;
mDhtState = RsDhtPeerDht::NOT_ACTIVE;
mDhtState = RSDHT_PEERDHT_SEARCHING;
mDhtState = RsDhtPeerDht::SEARCHING;
mDhtUpdateTS = time(NULL);
mPeerReqStatusMsg = "Just Added";

View file

@ -44,12 +44,15 @@ enum class RsDhtPeerType : uint8_t
FRIEND = 3
};
#define RSDHT_PEERDHT_NOT_ACTIVE 0x0000
#define RSDHT_PEERDHT_SEARCHING 0x0001
#define RSDHT_PEERDHT_FAILURE 0x0002
#define RSDHT_PEERDHT_OFFLINE 0x0003
#define RSDHT_PEERDHT_UNREACHABLE 0x0004
#define RSDHT_PEERDHT_ONLINE 0x0005
enum class RsDhtPeerDht : uint8_t
{
NOT_ACTIVE = 0,
SEARCHING = 1,
FAILURE = 2,
OFFLINE = 3,
UNREACHABLE = 4,
ONLINE = 5
};
#define RSDHT_PEERCONN_DISCONNECTED 1
#define RSDHT_PEERCONN_UDP_STARTED 2
@ -106,7 +109,7 @@ class RsDhtNetPeer
RsPeerId mRsId;
RsDhtPeerType mPeerType;
uint32_t mDhtState;
RsDhtPeerDht mDhtState;
std::string mConnectState; // connectLogic.