fixed small bug in global router causing incoming messages to be in SENT mode

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@8176 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
csoler 2015-04-27 22:01:31 +00:00
parent ff6f14b7de
commit a52031ac58
2 changed files with 94 additions and 89 deletions

View File

@ -197,7 +197,7 @@
#include "grouterclientservice.h" #include "grouterclientservice.h"
/**********************/ /**********************/
//#define GROUTER_DEBUG #define GROUTER_DEBUG
/**********************/ /**********************/
const std::string p3GRouter::SERVICE_INFO_APP_NAME = "Global Router" ; const std::string p3GRouter::SERVICE_INFO_APP_NAME = "Global Router" ;
@ -440,7 +440,7 @@ void p3GRouter::handleLowLevelTransactionAckItem(RsGRouterTransactionAcknItem *t
std::map<GRouterMsgPropagationId, GRouterRoutingInfo>::iterator it=_pending_messages.find(trans_ack_item->propagation_id) ; std::map<GRouterMsgPropagationId, GRouterRoutingInfo>::iterator it=_pending_messages.find(trans_ack_item->propagation_id) ;
if(it != _pending_messages.end()) if(it != _pending_messages.end() && it->second.data_status == RS_GROUTER_DATA_STATUS_ONGOING)
{ {
it->second.data_status = RS_GROUTER_DATA_STATUS_SENT; it->second.data_status = RS_GROUTER_DATA_STATUS_SENT;
it->second.last_sent_TS = time(NULL) ; it->second.last_sent_TS = time(NULL) ;
@ -1479,28 +1479,28 @@ void p3GRouter::handleIncomingDataItem(RsGRouterGenericDataItem *data_item)
item_is_for_us = _owned_key_ids.find( makeTunnelHash(data_item->destination_key,service_id) ) != _owned_key_ids.end() ; item_is_for_us = _owned_key_ids.find( makeTunnelHash(data_item->destination_key,service_id) ) != _owned_key_ids.end() ;
#ifdef GROUTER_DEBUG #ifdef GROUTER_DEBUG
std::cerr << " item is " << (item_is_for_us?"":"not") << " for us." << std::endl; std::cerr << " item is " << (item_is_for_us?"":"not") << " for us." << std::endl;
#endif #endif
std::map<GRouterMsgPropagationId,GRouterRoutingInfo>::iterator it = _pending_messages.find(data_item->routing_id) ; std::map<GRouterMsgPropagationId,GRouterRoutingInfo>::iterator it = _pending_messages.find(data_item->routing_id) ;
if(it != _pending_messages.end()) if(it != _pending_messages.end())
{
if(it->second.item_hash != item_hash)
{ {
if(it->second.item_hash != item_hash)
{
#ifdef GROUTER_DEBUG #ifdef GROUTER_DEBUG
std::cerr << " ERROR: item is already known but data hash does not match. Dropping that item." << std::endl; std::cerr << " ERROR: item is already known but data hash does not match. Dropping that item." << std::endl;
#endif
return ;
}
item_is_already_known = true ;
receipt_item = it->second.receipt_item ;
#ifdef GROUTER_DEBUG
std::cerr << " item is already in cache." << std::endl;
#endif #endif
return ;
} }
item_is_already_known = true ;
receipt_item = it->second.receipt_item ;
#ifdef GROUTER_DEBUG #ifdef GROUTER_DEBUG
std::cerr << " item is already in cache." << std::endl; else
#endif std::cerr << " item is new." << std::endl;
}
#ifdef GROUTER_DEBUG
else
std::cerr << " item is new." << std::endl;
#endif #endif
} }
// At this point, if item is already known, it is guarrantied to be identical to the stored item. // At this point, if item is already known, it is guarrantied to be identical to the stored item.
@ -1522,8 +1522,6 @@ void p3GRouter::handleIncomingDataItem(RsGRouterGenericDataItem *data_item)
else else
std::cerr << " verifying item signature: CHECKED!" ; std::cerr << " verifying item signature: CHECKED!" ;
#endif #endif
// No we need to send a signed receipt to the sender. // No we need to send a signed receipt to the sender.
receipt_item = new RsGRouterSignedReceiptItem; receipt_item = new RsGRouterSignedReceiptItem;

View File

@ -121,70 +121,70 @@ GlobalRouterStatisticsWidget::GlobalRouterStatisticsWidget(QWidget *parent)
void GlobalRouterStatisticsWidget::updateContent() void GlobalRouterStatisticsWidget::updateContent()
{ {
std::vector<RsGRouter::GRouterRoutingCacheInfo> cache_infos ; std::vector<RsGRouter::GRouterRoutingCacheInfo> cache_infos ;
RsGRouter::GRouterRoutingMatrixInfo matrix_info ; RsGRouter::GRouterRoutingMatrixInfo matrix_info ;
rsGRouter->getRoutingCacheInfo(cache_infos) ; rsGRouter->getRoutingCacheInfo(cache_infos) ;
rsGRouter->getRoutingMatrixInfo(matrix_info) ; rsGRouter->getRoutingMatrixInfo(matrix_info) ;
// What do we need to draw? // What do we need to draw?
// //
// Routing matrix // Routing matrix
// Key [][][][][][][][][][] // Key [][][][][][][][][][]
// //
// -> each [] shows a square (one per friend node) that is the routing probabilities for all connected friends // -> each [] shows a square (one per friend node) that is the routing probabilities for all connected friends
// computed using the "computeRoutingProbabilitites()" method. // computed using the "computeRoutingProbabilitites()" method.
// //
// Own key ids // Own key ids
// key service id description // key service id description
// //
// Data items // Data items
// Msg id Local origin Destination Time Status // Msg id Local origin Destination Time Status
// //
QPixmap tmppixmap(maxWidth, maxHeight); QPixmap tmppixmap(maxWidth, maxHeight);
tmppixmap.fill(this, 0, 0); tmppixmap.fill(this, 0, 0);
setFixedHeight(maxHeight); setFixedHeight(maxHeight);
QPainter painter(&tmppixmap); QPainter painter(&tmppixmap);
painter.initFrom(this); painter.initFrom(this);
painter.setPen(QColor::fromRgb(0,0,0)) ; painter.setPen(QColor::fromRgb(0,0,0)) ;
QFont times_f("Times") ; QFont times_f("Times") ;
QFont monospace_f("Monospace") ; QFont monospace_f("Monospace") ;
monospace_f.setStyleHint(QFont::TypeWriter) ; monospace_f.setStyleHint(QFont::TypeWriter) ;
QFontMetrics fm_monospace(monospace_f) ; QFontMetrics fm_monospace(monospace_f) ;
QFontMetrics fm_times(times_f) ; QFontMetrics fm_times(times_f) ;
static const int cellx = fm_monospace.width(QString(" ")) ; static const int cellx = fm_monospace.width(QString(" ")) ;
static const int celly = fm_monospace.height() ; static const int celly = fm_monospace.height() ;
maxHeight = 500 ; maxHeight = 500 ;
// std::cerr << "Drawing into pixmap of size " << maxWidth << "x" << maxHeight << std::endl; // std::cerr << "Drawing into pixmap of size " << maxWidth << "x" << maxHeight << std::endl;
// draw... // draw...
int ox=5,oy=5 ; int ox=5,oy=5 ;
painter.setFont(times_f) ;
painter.drawText(ox,oy+celly,tr("Managed keys")+":" + QString::number(matrix_info.published_keys.size())) ; oy += celly*2 ;
painter.setFont(monospace_f) ;
painter.setFont(times_f) ;
painter.drawText(ox,oy+celly,tr("Managed keys")+":" + QString::number(matrix_info.published_keys.size())) ; oy += celly*2 ;
painter.setFont(monospace_f) ;
for(std::map<Sha1CheckSum,RsGRouter::GRouterPublishedKeyInfo>::const_iterator it(matrix_info.published_keys.begin());it!=matrix_info.published_keys.end();++it) for(std::map<Sha1CheckSum,RsGRouter::GRouterPublishedKeyInfo>::const_iterator it(matrix_info.published_keys.begin());it!=matrix_info.published_keys.end();++it)
{ {
QString packet_string ; QString packet_string ;
packet_string += QString::fromStdString(it->second.authentication_key.toStdString()) ; packet_string += QString::fromStdString(it->second.authentication_key.toStdString()) ;
packet_string += tr(" : Service ID = ")+QString::number(it->second.service_id,16) ; packet_string += tr(" : Service ID = ")+QString::number(it->second.service_id,16) ;
packet_string += " \""+QString::fromUtf8(it->second.description_string.c_str()) + "\"" ; packet_string += " \""+QString::fromUtf8(it->second.description_string.c_str()) + "\"" ;
painter.drawText(ox+2*cellx,oy+celly,packet_string ) ; oy += celly ; painter.drawText(ox+2*cellx,oy+celly,packet_string ) ; oy += celly ;
} }
oy += celly ; oy += celly ;
painter.setFont(times_f) ; painter.setFont(times_f) ;
painter.drawText(ox,oy+celly,tr("Pending packets")+":" + QString::number(cache_infos.size())) ; oy += celly*2 ; painter.drawText(ox,oy+celly,tr("Pending packets")+":" + QString::number(cache_infos.size())) ; oy += celly*2 ;
painter.setFont(monospace_f) ; painter.setFont(monospace_f) ;
static const QString data_status_string[6] = { "Unkown","Pending","Sent","Receipt OK","Ongoing","Done" } ; static const QString data_status_string[6] = { "Unkown","Pending","Sent","Receipt OK","Ongoing","Done" } ;
static const QString tunnel_status_string[4] = { "Unmanaged", "Pending", "Ready" } ; static const QString tunnel_status_string[4] = { "Unmanaged", "Pending", "Ready" } ;
@ -194,14 +194,14 @@ void GlobalRouterStatisticsWidget::updateContent()
static const int nb_fields = 8 ; static const int nb_fields = 8 ;
static const QString fname[nb_fields] = { static const QString fname[nb_fields] = {
tr("Id"), tr("Id"),
tr("Destination"), tr("Destination"),
tr("Data status"), tr("Data status"),
tr("Tunnel status"), tr("Tunnel status"),
tr("Data size"), tr("Data size"),
tr("Data hash"), tr("Data hash"),
tr("Received"), tr("Received"),
tr("Send") } ; tr("Send") } ;
std::vector<int> max_column_width(nb_fields,0) ; std::vector<int> max_column_width(nb_fields,0) ;
@ -292,24 +292,31 @@ void GlobalRouterStatisticsWidget::updateContent()
for(std::map<GRouterKeyId,std::vector<float> >::const_iterator it(matrix_info.per_friend_probabilities.begin());it!=matrix_info.per_friend_probabilities.end();++it) for(std::map<GRouterKeyId,std::vector<float> >::const_iterator it(matrix_info.per_friend_probabilities.begin());it!=matrix_info.per_friend_probabilities.end();++it)
{ {
QString ids = QString::fromStdString(it->first.toStdString())+" : " ; bool is_null = true ;
painter.drawText(ox+2*cellx,oy+celly,ids) ;
for(uint32_t i=0;i<matrix_info.friend_ids.size();++i) for(uint32_t i=0;i<matrix_info.friend_ids.size();++i)
painter.fillRect(ox+i*cellx+fm_monospace.width(ids),oy,cellx,celly,colorScale(it->second[i])) ; if(it->second[i] > 0.0)
is_null = false ;
oy += celly ; if(!is_null)
{
QString ids = QString::fromStdString(it->first.toStdString())+" : " ;
painter.drawText(ox+2*cellx,oy+celly,ids) ;
for(uint32_t i=0;i<matrix_info.friend_ids.size();++i)
painter.fillRect(ox+i*cellx+fm_monospace.width(ids),oy,cellx,celly,colorScale(it->second[i])) ;
oy += celly ;
}
} }
oy += celly ;
oy += celly ;
// update the pixmap
oy += celly ; //
oy += celly ; pixmap = tmppixmap;
maxHeight = oy ;
// update the pixmap
//
pixmap = tmppixmap;
maxHeight = oy ;
} }
QString GlobalRouterStatisticsWidget::speedString(float f) QString GlobalRouterStatisticsWidget::speedString(float f)