fixed bug in setting MaxRate values

This commit is contained in:
csoler 2016-06-09 23:23:51 -04:00
parent f5ad8b49be
commit 83a143476e
5 changed files with 17 additions and 54 deletions

View File

@ -2116,18 +2116,15 @@ bool p3PeerMgrIMPL::setMaxRates(const RsPgpId& pid,uint32_t maxUp,uint32_t maxDn
{
RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/
std::map<RsPgpId, PeerBandwidthLimits>::iterator it = mPeerBandwidthLimits.find(pid) ;
PeerBandwidthLimits& p(mPeerBandwidthLimits[pid]) ;
if(mPeerBandwidthLimits.end() == it)
return false ;
if(maxUp == it->second.max_up_rate_kbs && maxDn == it->second.max_dl_rate_kbs)
if(maxUp == p.max_up_rate_kbs && maxDn == p.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.max_up_rate_kbs = maxUp ;
it->second.max_dl_rate_kbs = maxDn ;
p.max_up_rate_kbs = maxUp ;
p.max_dl_rate_kbs = maxDn ;
IndicateConfigChanged();

View File

@ -209,9 +209,9 @@ virtual uint32_t getHiddenType(const RsPeerId &ssl_id) = 0;
virtual int getFriendCount(bool ssl, bool online) = 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;
virtual bool getMaxRates(const RsPeerId& pid,uint32_t& maxR,uint32_t& minR)=0;
virtual bool setMaxRates(const RsPgpId& pid,uint32_t maxUp,uint32_t maxDn)=0;
virtual bool getMaxRates(const RsPgpId& pid,uint32_t& maxUp,uint32_t& maxDn)=0;
virtual bool getMaxRates(const RsPeerId& pid,uint32_t& maxUp,uint32_t& maxDn)=0;
/************* DEPRECIATED FUNCTIONS (TO REMOVE) ********/
@ -326,9 +326,9 @@ 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 RsPgpId& pid,uint32_t maxR,uint32_t minR);
virtual bool getMaxRates(const RsPgpId& 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 maxUp,uint32_t maxDn);
virtual bool getMaxRates(const RsPgpId& pid,uint32_t& maxUp,uint32_t& maxDn);
virtual bool getMaxRates(const RsPeerId& pid,uint32_t& maxUp,uint32_t& maxDn);
/************************************************************************************************/
/* Extra IMPL Functions (used by p3LinkMgr, p3NetMgr + Setup) */

View File

@ -276,9 +276,6 @@ class RsPeerDetails
/* linkType */
uint32_t linkType;
uint32_t maxRateUp;
uint32_t maxRateDn;
};
// This class is used to get info about crytographic algorithms used with a

View File

@ -286,9 +286,6 @@ bool p3Peers::getPeerDetails(const RsPeerId& id, RsPeerDetails &d)
return false;
}
d.maxRateUp = ps.maxUpRate ;
d.maxRateDn = ps.maxDnRate ;
/* get from gpg (first), to fill in the sign and trust details */
/* don't return now, we've got fill in the ssl and connection info */
getGPGDetails(ps.gpg_id, d);

View File

@ -145,26 +145,8 @@ void PGPKeyDialog::load()
ui.make_friend_button->setToolTip("") ;
}
//ui._direct_transfer_CB->setChecked( detail.service_perm_flags & RS_NODE_PERM_DIRECT_DL ) ;
//ui._allow_push_CB->setChecked( detail.service_perm_flags & RS_NODE_PERM_ALLOW_PUSH) ;
ui.name->setText(QString::fromUtf8(detail.name.c_str()));
//ui.peerid->setText(QString::fromStdString(detail.id.toStdString()));
//RetroShareLink link;
//link.createPerson(detail.gpg_id);
//ui.rsid->setText(QString::fromStdString(detail.gpg_id.toStdString())) ;
ui.pgpfingerprint->setText(misc::fingerPrintStyleSplit(QString::fromStdString(detail.fpr.toStdString())));
//ui.rsid->setToolTip(link.title());
//ui.avatar->setId(pgpId.toStdString(), true);
// ui.rsid->show();
// ui.peerid->hide();
// ui.label_id->hide();
// ui.label_rsid->show();
ui.pgpfingerprint->show();
ui.pgpfingerprint_label->show();
@ -173,24 +155,14 @@ void PGPKeyDialog::load()
ui._allow_push_CB->setChecked( detail.service_perm_flags & RS_NODE_PERM_ALLOW_PUSH) ;
ui._require_WL_CB->setChecked( detail.service_perm_flags & RS_NODE_PERM_REQUIRE_WL) ;
ui.maxUploadSpeed_SB->setValue(detail.maxRateUp) ;
ui.maxDownloadSpeed_SB->setValue(detail.maxRateDn) ;
uint32_t max_upload_speed = 0 ;
uint32_t max_download_speed = 0 ;
rsPeers->getPeerMaximumRates(pgpId,max_upload_speed,max_download_speed);
ui.maxUploadSpeed_SB->setValue(max_upload_speed) ;
ui.maxDownloadSpeed_SB->setValue(max_download_speed) ;
// ui.loc->hide();
// ui.label_loc->hide();
// ui.statusline->hide();
// ui.label_status->hide();
// ui.lastcontact->hide();
// ui.label_last_contact->hide();
// ui.version->hide();
// ui.label_version->hide();
// ui.groupBox_4->hide();
// ui.crypto_info->hide();
// ui.crypto_label->hide();
// ui.groupBox->hide();
// ui.tabWidget->hide();
if (detail.gpg_id == rsPeers->getGPGOwnId())
{
ui.make_friend_button->hide();