diff --git a/libretroshare/src/grouter/p3grouter.cc b/libretroshare/src/grouter/p3grouter.cc index 1545a63d1..bf30753fd 100644 --- a/libretroshare/src/grouter/p3grouter.cc +++ b/libretroshare/src/grouter/p3grouter.cc @@ -197,7 +197,7 @@ #include "grouterclientservice.h" /**********************/ -//#define GROUTER_DEBUG +#define GROUTER_DEBUG /**********************/ const std::string p3GRouter::SERVICE_INFO_APP_NAME = "Global Router" ; @@ -440,7 +440,7 @@ void p3GRouter::handleLowLevelTransactionAckItem(RsGRouterTransactionAcknItem *t std::map::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.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() ; #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 - std::map::iterator it = _pending_messages.find(data_item->routing_id) ; + std::map::iterator it = _pending_messages.find(data_item->routing_id) ; - if(it != _pending_messages.end()) - { - if(it->second.item_hash != item_hash) + if(it != _pending_messages.end()) { + if(it->second.item_hash != item_hash) + { #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 - 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 - } -#ifdef GROUTER_DEBUG - else - std::cerr << " item is new." << std::endl; + else + std::cerr << " item is new." << std::endl; #endif } // 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 std::cerr << " verifying item signature: CHECKED!" ; #endif - - // No we need to send a signed receipt to the sender. receipt_item = new RsGRouterSignedReceiptItem; diff --git a/retroshare-gui/src/gui/statistics/GlobalRouterStatistics.cpp b/retroshare-gui/src/gui/statistics/GlobalRouterStatistics.cpp index cd3d0e196..5aa6e3bd4 100644 --- a/retroshare-gui/src/gui/statistics/GlobalRouterStatistics.cpp +++ b/retroshare-gui/src/gui/statistics/GlobalRouterStatistics.cpp @@ -121,70 +121,70 @@ GlobalRouterStatisticsWidget::GlobalRouterStatisticsWidget(QWidget *parent) void GlobalRouterStatisticsWidget::updateContent() { - std::vector cache_infos ; - RsGRouter::GRouterRoutingMatrixInfo matrix_info ; + std::vector cache_infos ; + RsGRouter::GRouterRoutingMatrixInfo matrix_info ; - rsGRouter->getRoutingCacheInfo(cache_infos) ; - rsGRouter->getRoutingMatrixInfo(matrix_info) ; + rsGRouter->getRoutingCacheInfo(cache_infos) ; + rsGRouter->getRoutingMatrixInfo(matrix_info) ; - // What do we need to draw? - // - // Routing matrix - // Key [][][][][][][][][][] - // - // -> each [] shows a square (one per friend node) that is the routing probabilities for all connected friends - // computed using the "computeRoutingProbabilitites()" method. - // - // Own key ids - // key service id description - // - // Data items - // Msg id Local origin Destination Time Status - // - QPixmap tmppixmap(maxWidth, maxHeight); - tmppixmap.fill(this, 0, 0); - setFixedHeight(maxHeight); + // What do we need to draw? + // + // Routing matrix + // Key [][][][][][][][][][] + // + // -> each [] shows a square (one per friend node) that is the routing probabilities for all connected friends + // computed using the "computeRoutingProbabilitites()" method. + // + // Own key ids + // key service id description + // + // Data items + // Msg id Local origin Destination Time Status + // + QPixmap tmppixmap(maxWidth, maxHeight); + tmppixmap.fill(this, 0, 0); + setFixedHeight(maxHeight); - QPainter painter(&tmppixmap); - painter.initFrom(this); - painter.setPen(QColor::fromRgb(0,0,0)) ; + QPainter painter(&tmppixmap); + painter.initFrom(this); + painter.setPen(QColor::fromRgb(0,0,0)) ; - QFont times_f("Times") ; - QFont monospace_f("Monospace") ; - monospace_f.setStyleHint(QFont::TypeWriter) ; + QFont times_f("Times") ; + QFont monospace_f("Monospace") ; + monospace_f.setStyleHint(QFont::TypeWriter) ; - QFontMetrics fm_monospace(monospace_f) ; - QFontMetrics fm_times(times_f) ; + QFontMetrics fm_monospace(monospace_f) ; + QFontMetrics fm_times(times_f) ; - static const int cellx = fm_monospace.width(QString(" ")) ; - static const int celly = fm_monospace.height() ; + static const int cellx = fm_monospace.width(QString(" ")) ; + static const int celly = fm_monospace.height() ; - maxHeight = 500 ; + maxHeight = 500 ; - // std::cerr << "Drawing into pixmap of size " << maxWidth << "x" << maxHeight << std::endl; - // draw... - 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 ; + // std::cerr << "Drawing into pixmap of size " << maxWidth << "x" << maxHeight << std::endl; + // draw... + int ox=5,oy=5 ; - 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::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 += tr(" : Service ID = ")+QString::number(it->second.service_id,16) ; - packet_string += " \""+QString::fromUtf8(it->second.description_string.c_str()) + "\"" ; + packet_string += tr(" : Service ID = ")+QString::number(it->second.service_id,16) ; + packet_string += " \""+QString::fromUtf8(it->second.description_string.c_str()) + "\"" ; - painter.drawText(ox+2*cellx,oy+celly,packet_string ) ; oy += celly ; - } - oy += celly ; + painter.drawText(ox+2*cellx,oy+celly,packet_string ) ; oy += celly ; + } + oy += celly ; - painter.setFont(times_f) ; - painter.drawText(ox,oy+celly,tr("Pending packets")+":" + QString::number(cache_infos.size())) ; oy += celly*2 ; + painter.setFont(times_f) ; + 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 tunnel_status_string[4] = { "Unmanaged", "Pending", "Ready" } ; @@ -194,14 +194,14 @@ void GlobalRouterStatisticsWidget::updateContent() static const int nb_fields = 8 ; static const QString fname[nb_fields] = { - tr("Id"), - tr("Destination"), - tr("Data status"), - tr("Tunnel status"), - tr("Data size"), - tr("Data hash"), - tr("Received"), - tr("Send") } ; + tr("Id"), + tr("Destination"), + tr("Data status"), + tr("Tunnel status"), + tr("Data size"), + tr("Data hash"), + tr("Received"), + tr("Send") } ; std::vector max_column_width(nb_fields,0) ; @@ -292,24 +292,31 @@ void GlobalRouterStatisticsWidget::updateContent() for(std::map >::const_iterator it(matrix_info.per_friend_probabilities.begin());it!=matrix_info.per_friend_probabilities.end();++it) { - QString ids = QString::fromStdString(it->first.toStdString())+" : " ; - painter.drawText(ox+2*cellx,oy+celly,ids) ; + bool is_null = true ; for(uint32_t i=0;isecond[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;isecond[i])) ; + + oy += celly ; + } } + oy += celly ; + oy += celly ; - - oy += celly ; - oy += celly ; - - // update the pixmap - // - pixmap = tmppixmap; - maxHeight = oy ; + // update the pixmap + // + pixmap = tmppixmap; + maxHeight = oy ; } QString GlobalRouterStatisticsWidget::speedString(float f)