add json support to getWaitingDiscCount

This commit is contained in:
sehraf 2018-09-07 14:19:06 +02:00
parent be50400114
commit ae14a01d58
No known key found for this signature in database
GPG Key ID: DF09F6EAE356B2C6
3 changed files with 28 additions and 8 deletions

View File

@ -71,6 +71,15 @@ class RsDisc
*/
virtual bool getPeerVersion(const RsPeerId &id, std::string &versions) = 0;
/**
* @brief getWaitingDiscCount get the number of queued discovery packets.
* @jsonapi{development}
* @param[out] sendCount number of queued outgoing packets
* @param[out] recvCount number of queued incoming packets
* @return true on success false otherwise
*/
virtual bool getWaitingDiscCount(size_t &sendCount, size_t &recvCount) = 0;
/**
* @brief getWaitingDiscCount get the number of queued discovery packets.
* @param[out] sendCount number of queued outgoing packets

View File

@ -1177,6 +1177,15 @@ bool p3discovery2::getDiscFriends(const RsPeerId& id, std::list<RsPeerId> &proxy
}
bool p3discovery2::getWaitingDiscCount(size_t &sendCount, size_t &recvCount)
{
RsStackMutex stack(mDiscMtx); /********** STACK LOCKED MTX ******/
sendCount = mPendingDiscPgpCertOutList.size();
recvCount = mPendingDiscPgpCertInList.size();
return true;
}
bool p3discovery2::getDiscPgpFriends(const PGPID &pgp_id, std::list<PGPID> &proxyPgpIds)
{
@ -1245,14 +1254,15 @@ bool p3discovery2::getWaitingDiscCount(unsigned int *sendCount, unsigned int *re
return false;
}
RsStackMutex stack(mDiscMtx); /********** STACK LOCKED MTX ******/
size_t send, recv;
getWaitingDiscCount(send, recv);
if (sendCount) {
*sendCount = mPendingDiscPgpCertOutList.size();
*sendCount = send;
}
if (recvCount) {
*recvCount = mPendingDiscPgpCertInList.size();
*recvCount = recv;
}
return true;
}

View File

@ -87,10 +87,11 @@ virtual RsServiceInfo getServiceInfo();
int tick();
/* external interface */
virtual bool getDiscFriends(const RsPeerId &id, std::list<RsPeerId> &friends);
virtual bool getDiscPgpFriends(const RsPgpId &pgpid, std::list<RsPgpId> &gpg_friends);
virtual bool getPeerVersion(const RsPeerId &id, std::string &version);
virtual bool getWaitingDiscCount(unsigned int *sendCount, unsigned int *recvCount);
bool getDiscFriends(const RsPeerId &id, std::list<RsPeerId> &friends);
bool getDiscPgpFriends(const RsPgpId &pgpid, std::list<RsPgpId> &gpg_friends);
bool getPeerVersion(const RsPeerId &id, std::string &version);
bool getWaitingDiscCount(size_t &sendCount, size_t &recvCount);
bool getWaitingDiscCount(unsigned int *sendCount, unsigned int *recvCount);
/************* from AuthGPService ****************/
virtual AuthGPGOperation *getGPGOperation();