mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-08-07 22:02:32 -04:00
fixed setting/getting maxrates using pgp id
This commit is contained in:
parent
a07805be1d
commit
a4931edee0
7 changed files with 29 additions and 38 deletions
|
@ -2076,17 +2076,11 @@ bool p3PeerMgrIMPL::saveList(bool &cleanup, std::list<RsItem *>& saveData)
|
|||
return true;
|
||||
}
|
||||
|
||||
bool p3PeerMgrIMPL::getMaxRates(const RsPeerId& pid,uint32_t& maxUp,uint32_t& maxDn)
|
||||
bool p3PeerMgrIMPL::getMaxRates(const RsPgpId& pid,uint32_t& maxUp,uint32_t& maxDn)
|
||||
{
|
||||
RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/
|
||||
|
||||
/* check if it is a friend */
|
||||
std::map<RsPeerId, peerState>::iterator it = mFriendList.find(pid) ;
|
||||
|
||||
if(mFriendList.end() == it)
|
||||
return false ;
|
||||
|
||||
std::map<RsPgpId,PeerBandwidthLimits>::const_iterator it2 = mPeerBandwidthLimits.find(it->second.gpg_id) ;
|
||||
std::map<RsPgpId,PeerBandwidthLimits>::const_iterator it2 = mPeerBandwidthLimits.find(pid) ;
|
||||
|
||||
if(it2 != mPeerBandwidthLimits.end())
|
||||
{
|
||||
|
@ -2101,23 +2095,22 @@ bool p3PeerMgrIMPL::getMaxRates(const RsPeerId& pid,uint32_t& maxUp,uint32_t& ma
|
|||
return false ;
|
||||
}
|
||||
}
|
||||
bool p3PeerMgrIMPL::setMaxRates(const RsPeerId& pid,uint32_t maxUp,uint32_t maxDn)
|
||||
bool p3PeerMgrIMPL::setMaxRates(const RsPgpId& pid,uint32_t maxUp,uint32_t maxDn)
|
||||
{
|
||||
RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/
|
||||
|
||||
/* check if it is a friend */
|
||||
std::map<RsPeerId, peerState>::iterator it = mFriendList.find(pid) ;
|
||||
std::map<RsPgpId, PeerBandwidthLimits>::iterator it = mPeerBandwidthLimits.find(pid) ;
|
||||
|
||||
if(mFriendList.end() == it)
|
||||
if(mPeerBandwidthLimits.end() == it)
|
||||
return false ;
|
||||
|
||||
if(maxUp == it->second.maxUpRate && maxDn == it->second.maxDnRate)
|
||||
if(maxUp == it->second.max_up_rate_kbs && maxDn == it->second.max_dl_rate_kbs)
|
||||
return true ;
|
||||
|
||||
std::cerr << "Updating max rates for peer " << pid << " to " << maxUp << " kB/s (up), " << maxDn << " kB/s (dn)" << std::endl;
|
||||
|
||||
it->second.maxUpRate = maxUp ;
|
||||
it->second.maxDnRate = maxDn ;
|
||||
it->second.max_up_rate_kbs = maxUp ;
|
||||
it->second.max_dl_rate_kbs = maxDn ;
|
||||
|
||||
IndicateConfigChanged();
|
||||
|
||||
|
|
|
@ -209,8 +209,8 @@ virtual uint32_t getHiddenType(const RsPeerId &ssl_id) = 0;
|
|||
|
||||
|
||||
virtual int getFriendCount(bool ssl, bool online) = 0;
|
||||
virtual bool setMaxRates(const RsPeerId& pid,uint32_t maxR,uint32_t minR)=0;
|
||||
virtual bool getMaxRates(const RsPeerId& pid,uint32_t& maxR,uint32_t& minR)=0;
|
||||
virtual bool setMaxRates(const RsPgpId& pid,uint32_t maxR,uint32_t minR)=0;
|
||||
virtual bool getMaxRates(const RsPgpId& pid,uint32_t& maxR,uint32_t& minR)=0;
|
||||
|
||||
/************* DEPRECIATED FUNCTIONS (TO REMOVE) ********/
|
||||
|
||||
|
@ -325,8 +325,8 @@ virtual int getFriendCount(bool ssl, bool online);
|
|||
// Single Use Function... shouldn't be here. used by p3serverconfig.cc
|
||||
virtual bool haveOnceConnected();
|
||||
|
||||
virtual bool setMaxRates(const RsPeerId& pid,uint32_t maxR,uint32_t minR);
|
||||
virtual bool getMaxRates(const RsPeerId& pid,uint32_t& maxR,uint32_t& minR);
|
||||
virtual bool setMaxRates(const RsPgpId& pid,uint32_t maxR,uint32_t minR);
|
||||
virtual bool getMaxRates(const RsPgpId& pid,uint32_t& maxR,uint32_t& minR);
|
||||
|
||||
/************************************************************************************************/
|
||||
/* Extra IMPL Functions (used by p3LinkMgr, p3NetMgr + Setup) */
|
||||
|
|
|
@ -432,8 +432,8 @@ public:
|
|||
virtual ServicePermissionFlags servicePermissionFlags(const RsPeerId& ssl_id) = 0;
|
||||
virtual void setServicePermissionFlags(const RsPgpId& gpg_id,const ServicePermissionFlags& flags) = 0;
|
||||
|
||||
virtual bool setPeerMaximumRates(const RsPeerId& pid,uint32_t maxUploadRate,uint32_t maxDownloadRate) =0;
|
||||
virtual bool getPeerMaximumRates(const RsPeerId& pid,uint32_t& maxUploadRate,uint32_t& maxDownloadRate) =0;
|
||||
virtual bool setPeerMaximumRates(const RsPgpId& pid,uint32_t maxUploadRate,uint32_t maxDownloadRate) =0;
|
||||
virtual bool getPeerMaximumRates(const RsPgpId& pid,uint32_t& maxUploadRate,uint32_t& maxDownloadRate) =0;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -241,12 +241,12 @@ bool p3Peers::isFriend(const RsPeerId &ssl_id)
|
|||
return mPeerMgr->isFriend(ssl_id);
|
||||
}
|
||||
|
||||
bool p3Peers::getPeerMaximumRates(const RsPeerId& pid,uint32_t& maxUploadRate,uint32_t& maxDownloadRate)
|
||||
bool p3Peers::getPeerMaximumRates(const RsPgpId& pid,uint32_t& maxUploadRate,uint32_t& maxDownloadRate)
|
||||
{
|
||||
return mPeerMgr->getMaxRates(pid,maxUploadRate,maxDownloadRate) ;
|
||||
}
|
||||
|
||||
bool p3Peers::setPeerMaximumRates(const RsPeerId& pid,uint32_t maxUploadRate,uint32_t maxDownloadRate)
|
||||
bool p3Peers::setPeerMaximumRates(const RsPgpId& pid,uint32_t maxUploadRate,uint32_t maxDownloadRate)
|
||||
{
|
||||
return mPeerMgr->setMaxRates(pid,maxUploadRate,maxDownloadRate) ;
|
||||
}
|
||||
|
|
|
@ -139,8 +139,8 @@ public:
|
|||
virtual ServicePermissionFlags servicePermissionFlags(const RsPeerId & ssl_id);
|
||||
virtual void setServicePermissionFlags(const RsPgpId& gpg_id,const ServicePermissionFlags& flags);
|
||||
|
||||
virtual bool setPeerMaximumRates(const RsPeerId& pid,uint32_t maxUploadRate,uint32_t maxDownloadRate);
|
||||
virtual bool getPeerMaximumRates(const RsPeerId& pid,uint32_t& maxUploadRate,uint32_t& maxDownloadRate);
|
||||
virtual bool setPeerMaximumRates(const RsPgpId& pid,uint32_t maxUploadRate,uint32_t maxDownloadRate);
|
||||
virtual bool getPeerMaximumRates(const RsPgpId& pid,uint32_t& maxUploadRate,uint32_t& maxDownloadRate);
|
||||
private:
|
||||
|
||||
p3LinkMgr *mLinkMgr;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue