mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-04-11 18:29:16 -04:00
improvements to global router: longer half-life for routing events, re-sending of un-delivered items, removed unused constants, added missing file to .pro
git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@8148 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
69612c0c86
commit
a9ba944e27
@ -203,8 +203,7 @@ RsGRouterRoutingInfoItem *RsGRouterSerialiser::deserialise_RsGRouterRoutingInfoI
|
||||
ok &= getRawUInt32(data, pktsize, &offset, &item->data_status);
|
||||
ok &= getRawUInt32(data, pktsize, &offset, &item->tunnel_status);
|
||||
ok &= getRawTimeT(data, pktsize, &offset, item->received_time_TS);
|
||||
ok &= getRawTimeT(data, pktsize, &offset, item->last_tunnel_sent_TS);
|
||||
ok &= getRawTimeT(data, pktsize, &offset, item->last_friend_sent_TS);
|
||||
ok &= getRawTimeT(data, pktsize, &offset, item->last_sent_TS);
|
||||
|
||||
ok &= getRawTimeT(data, pktsize, &offset, item->last_tunnel_request_TS);
|
||||
ok &= getRawUInt32(data, pktsize, &offset, &item->sending_attempts);
|
||||
@ -568,8 +567,7 @@ uint32_t RsGRouterRoutingInfoItem::serial_size() const
|
||||
s += 4 ; // data status_flags
|
||||
s += 4 ; // tunnel status_flags
|
||||
s += 8 ; // received_time
|
||||
s += 8 ; // last_tunnel_sent_TS
|
||||
s += 8 ; // last_friend_sent_TS
|
||||
s += 8 ; // last_sent_TS
|
||||
|
||||
s += 8 ; // last_TR_TS
|
||||
s += 4 ; // sending attempts
|
||||
@ -669,8 +667,7 @@ bool RsGRouterRoutingInfoItem::serialise(void *data,uint32_t& size) const
|
||||
ok &= setRawUInt32(data, tlvsize, &offset, data_status) ;
|
||||
ok &= setRawUInt32(data, tlvsize, &offset, tunnel_status) ;
|
||||
ok &= setRawTimeT(data, tlvsize, &offset, received_time_TS) ;
|
||||
ok &= setRawTimeT(data, tlvsize, &offset, last_tunnel_sent_TS) ;
|
||||
ok &= setRawTimeT(data, tlvsize, &offset, last_friend_sent_TS) ;
|
||||
ok &= setRawTimeT(data, tlvsize, &offset, last_sent_TS) ;
|
||||
ok &= setRawTimeT(data, tlvsize, &offset, last_tunnel_request_TS) ;
|
||||
ok &= setRawUInt32(data, tlvsize, &offset, sending_attempts) ;
|
||||
|
||||
@ -737,8 +734,7 @@ std::ostream& RsGRouterRoutingInfoItem::print(std::ostream& o, uint16_t)
|
||||
o << " data status: "<< std::hex<< data_status << std::dec << std::endl ;
|
||||
o << " tunnel status: "<< tunnel_status << std::endl ;
|
||||
o << " recv time: "<< received_time_TS << std::endl ;
|
||||
o << " Last tunnel sent: "<< last_tunnel_sent_TS << std::endl ;
|
||||
o << " Last friend sent: "<< last_friend_sent_TS << std::endl ;
|
||||
o << " Last sent: "<< last_sent_TS << std::endl ;
|
||||
o << " Sending attempts:"<< sending_attempts << std::endl ;
|
||||
o << " destination key: "<< data_item->destination_key << std::endl ;
|
||||
o << " Client id: "<< client_id << std::endl ;
|
||||
|
@ -46,9 +46,7 @@ const uint8_t RS_PKT_SUBTYPE_GROUTER_TRANSACTION_ACKN = 0x11 ; // ac
|
||||
|
||||
const uint8_t RS_PKT_SUBTYPE_GROUTER_MATRIX_CLUES = 0x80 ; // item to save matrix clues
|
||||
const uint8_t RS_PKT_SUBTYPE_GROUTER_FRIENDS_LIST = 0x82 ; // item to save friend lists
|
||||
const uint8_t RS_PKT_SUBTYPE_GROUTER_ROUTING_INFO_deprecated = 0x87 ; // deprecated. Don't use.
|
||||
const uint8_t RS_PKT_SUBTYPE_GROUTER_ROUTING_INFO_deprecated2 = 0x88 ; // item to save routing info
|
||||
const uint8_t RS_PKT_SUBTYPE_GROUTER_ROUTING_INFO = 0x92 ; //
|
||||
const uint8_t RS_PKT_SUBTYPE_GROUTER_ROUTING_INFO = 0x93 ; //
|
||||
|
||||
const uint8_t QOS_PRIORITY_RS_GROUTER = 4 ; // relevant for items that travel through friends
|
||||
|
||||
|
@ -210,8 +210,10 @@ bool GRouterMatrix::updateRoutingProbabilities()
|
||||
v.resize(_friend_indices.size(),0.0f) ;
|
||||
|
||||
for(std::list<RoutingMatrixHitEntry>::const_iterator it2(it->second.begin());it2!=it->second.end();++it2)
|
||||
{
|
||||
float time_difference_in_days = 1 + (now - (*it2).time_stamp ) / 86400.0f ;
|
||||
{
|
||||
// Half life period is 7 days.
|
||||
|
||||
float time_difference_in_days = 1 + (now - (*it2).time_stamp ) / (7*86400.0f) ;
|
||||
v[(*it2).friend_id] += (*it2).weight / (time_difference_in_days*time_difference_in_days) ;
|
||||
}
|
||||
}
|
||||
|
@ -46,21 +46,17 @@ static const float RS_GROUTER_BASE_WEIGHT_GXS_PACKET = 0.1f ; // base c
|
||||
|
||||
static const uint32_t MAX_TUNNEL_WAIT_TIME = 60 ; // wait for 60 seconds at most for a tunnel response.
|
||||
static const uint32_t MAX_TUNNEL_UNMANAGED_TIME = 600 ; // min time before retry tunnels for that msg.
|
||||
static const uint32_t MAX_DELAY_BETWEEN_TWO_SEND = 120 ; // wait for 120 seconds before re-sending.
|
||||
static const uint32_t MAX_DELAY_FOR_RESEND = 2*86400+300 ; // re-send if held for more than 2 days (cache store period) plus security delay.
|
||||
static const uint32_t TUNNEL_OK_WAIT_TIME = 2 ; // wait for 2 seconds after last tunnel ok, so that we have a complete set of tunnels.
|
||||
static const uint32_t MAX_GROUTER_DATA_SIZE = 2*1024*1024 ; // 2MB size limit. This is of course arbitrary.
|
||||
static const uint32_t MAX_RECEIPT_WAIT_TIME = 20 ; // wait for at most 20 secs for a receipt. If not, cancel.
|
||||
static const uint32_t MAX_TRANSACTION_ACK_WAITING_TIME = 60 ; // wait for at most 60 secs for a ACK. If not restart the transaction.
|
||||
static const uint32_t DIRECT_FRIEND_TRY_DELAY = 20 ; // wait for 20 secs if no friends available, then try tunnels.
|
||||
static const uint32_t MAX_INACTIVE_DATA_PIPE_DELAY = 300 ; // clean inactive data pipes for more than 5 mins
|
||||
|
||||
static const time_t RS_GROUTER_DEBUG_OUTPUT_PERIOD = 10 ; // Output everything
|
||||
static const time_t RS_GROUTER_AUTOWASH_PERIOD = 10 ; // Autowash every minute. Not a costly operation.
|
||||
static const time_t RS_GROUTER_MATRIX_UPDATE_PERIOD = 1 *10 ; // Check for key advertising every 10 minutes
|
||||
static const time_t RS_GROUTER_ROUTING_WAITING_TIME = 2 *60 ; // time between two trial of sending a given message
|
||||
//atic const time_t RS_GROUTER_ROUTING_WAITING_TIME = 3600 ; // time between two trial of sending a given message
|
||||
static const time_t RS_GROUTER_MEAN_EXPECTED_RTT = 30 ; // reference RTT time for a message.
|
||||
static const uint32_t GROUTER_ITEM_MAX_CACHE_KEEP_TIME = 86400 ; // Cached items are kept for 24 hours at most.
|
||||
static const time_t RS_GROUTER_DEBUG_OUTPUT_PERIOD = 10 ; // Output everything
|
||||
static const time_t RS_GROUTER_AUTOWASH_PERIOD = 10 ; // Autowash every minute. Not a costly operation.
|
||||
static const time_t RS_GROUTER_MATRIX_UPDATE_PERIOD = 1 *10 ; // Check for key advertising every 10 minutes
|
||||
static const uint32_t GROUTER_ITEM_MAX_CACHE_KEEP_TIME = 2*86400 ; // Cached items are kept for 48 hours at most.
|
||||
|
||||
static const uint32_t RS_GROUTER_DATA_STATUS_UNKNOWN = 0x0000 ; // unknown. Unused.
|
||||
static const uint32_t RS_GROUTER_DATA_STATUS_PENDING = 0x0001 ; // item is pending. Should be sent asap.
|
||||
@ -72,10 +68,9 @@ static const uint32_t RS_GROUTER_DATA_STATUS_DONE = 0x0005 ; // receipt
|
||||
static const uint32_t RS_GROUTER_SENDING_STATUS_TUNNEL = 0x0001 ; // item was sent in a tunnel
|
||||
static const uint32_t RS_GROUTER_SENDING_STATUS_FRIEND = 0x0002 ; // item was sent to a friend
|
||||
|
||||
static const uint32_t RS_GROUTER_TUNNEL_STATUS_UNMANAGED = 0x0000 ; // no tunnel requested atm
|
||||
static const uint32_t RS_GROUTER_TUNNEL_STATUS_PENDING = 0x0001 ; // tunnel requested to turtle
|
||||
static const uint32_t RS_GROUTER_TUNNEL_STATUS_READY = 0x0002 ; // tunnel is ready but we're still waiting for various confirmations
|
||||
//static const uint32_t RS_GROUTER_TUNNEL_STATUS_CAN_SEND = 0x0003 ; // tunnel is ready and data can be sent
|
||||
static const uint32_t RS_GROUTER_TUNNEL_STATUS_UNMANAGED = 0x0000 ; // no tunnel requested atm
|
||||
static const uint32_t RS_GROUTER_TUNNEL_STATUS_PENDING = 0x0001 ; // tunnel requested to turtle
|
||||
static const uint32_t RS_GROUTER_TUNNEL_STATUS_READY = 0x0002 ; // tunnel is ready but we're still waiting for various confirmations
|
||||
|
||||
class FriendTrialRecord
|
||||
{
|
||||
@ -105,8 +100,7 @@ public:
|
||||
uint32_t tunnel_status ; // status of tunnel handling.
|
||||
|
||||
time_t received_time_TS ; // time at which the item was originally received
|
||||
time_t last_tunnel_sent_TS ; // last time the item was sent to friends
|
||||
time_t last_friend_sent_TS ; // last time the item was sent to friends
|
||||
time_t last_sent_TS ; // last time the item was sent
|
||||
time_t last_tunnel_request_TS ; // last time tunnels have been asked for this item.
|
||||
uint32_t sending_attempts ; // number of times tunnels have been asked for this peer without success
|
||||
|
||||
|
@ -515,11 +515,7 @@ void p3GRouter::handleLowLevelTransactionAckItem(RsGRouterTransactionAcknItem *t
|
||||
if(it != _pending_messages.end())
|
||||
{
|
||||
it->second.data_status = RS_GROUTER_DATA_STATUS_SENT;
|
||||
|
||||
if(mTurtle->isTurtlePeer(trans_ack_item->PeerId()))
|
||||
it->second.last_tunnel_sent_TS = time(NULL) ;
|
||||
else
|
||||
it->second.last_friend_sent_TS = time(NULL) ;
|
||||
it->second.last_sent_TS = time(NULL) ;
|
||||
#ifdef GROUTER_DEBUG
|
||||
std::cerr << " setting new status as sent/awaiting receipt." << std::endl;
|
||||
#endif
|
||||
@ -799,17 +795,16 @@ void p3GRouter::handleTunnels()
|
||||
|
||||
// Delay after which a message is re-sent, depending on the number of attempts already made.
|
||||
|
||||
RS_STACK_MUTEX(grMtx) ;
|
||||
RS_STACK_MUTEX(grMtx) ;
|
||||
|
||||
#ifdef GROUTER_DEBUG
|
||||
if(!_pending_messages.empty())
|
||||
{
|
||||
grouter_debug() << "p3GRouter::handleTunnels()" << std::endl;
|
||||
grouter_debug() << " building priority list of items to send..." << std::endl;
|
||||
}
|
||||
if(!_pending_messages.empty())
|
||||
{
|
||||
grouter_debug() << "p3GRouter::handleTunnels()" << std::endl;
|
||||
grouter_debug() << " building priority list of items to send..." << std::endl;
|
||||
}
|
||||
#endif
|
||||
|
||||
static uint32_t send_retry_time_delays[6] = { 0, 1800, 3600, 5*3600, 12*3600, 24*2600 } ;
|
||||
time_t now = time(NULL) ;
|
||||
std::vector<std::pair<int,GRouterRoutingInfo*> > priority_list ;
|
||||
|
||||
@ -820,8 +815,7 @@ if(!_pending_messages.empty())
|
||||
<< ", data_status=" << it->second.data_status << ", tunnel_status=" << it->second.tunnel_status
|
||||
<< ", last received: "<< now - it->second.received_time_TS << " (secs ago)"
|
||||
<< ", last TR: "<< now - it->second.last_tunnel_request_TS << " (secs ago)"
|
||||
<< ", last tunnel sent: " << now - it->second.last_tunnel_sent_TS << " (secs ago) "
|
||||
<< ", last friend sent: " << now - it->second.last_friend_sent_TS << " (secs ago) " ;
|
||||
<< ", last sent: " << now - it->second.last_sent_TS << " (secs ago) "<< std::endl;
|
||||
#endif
|
||||
|
||||
if(it->second.data_status == RS_GROUTER_DATA_STATUS_PENDING && (it->second.routing_flags & GRouterRoutingInfo::ROUTING_FLAGS_ALLOW_TUNNELS))
|
||||
@ -829,7 +823,7 @@ if(!_pending_messages.empty())
|
||||
if(it->second.tunnel_status == RS_GROUTER_TUNNEL_STATUS_UNMANAGED && it->second.last_tunnel_request_TS + MAX_TUNNEL_UNMANAGED_TIME < now)
|
||||
{
|
||||
uint32_t item_delay = now - it->second.last_tunnel_request_TS ;
|
||||
int item_priority = item_delay - send_retry_time_delays[std::min(5u,it->second.sending_attempts)] ;
|
||||
int item_priority = item_delay ;
|
||||
|
||||
#ifdef GROUTER_DEBUG
|
||||
grouter_debug() << " delay=" << item_delay << " attempts=" << it->second.sending_attempts << ", priority=" << item_priority << std::endl;
|
||||
@ -857,44 +851,28 @@ if(!_pending_messages.empty())
|
||||
grouter_debug() << std::endl;
|
||||
#endif
|
||||
}
|
||||
else if(it->second.data_status == RS_GROUTER_DATA_STATUS_RECEIPT_OK )
|
||||
{
|
||||
#ifdef GROUTER_DEBUG
|
||||
std::cerr << " closing pending tunnels." << std::endl;
|
||||
#endif
|
||||
mTurtle->stopMonitoringTunnels(it->second.tunnel_hash) ;
|
||||
|
||||
it->second.tunnel_status = RS_GROUTER_TUNNEL_STATUS_UNMANAGED ;
|
||||
}
|
||||
else if(it->second.data_status == RS_GROUTER_DATA_STATUS_SENT)// && it->second.last_tunnel_sent_TS + MAX_RECEIPT_WAIT_TIME < now)
|
||||
{
|
||||
#ifdef GROUTER_DEBUG
|
||||
std::cerr << " closing pending tunnels." << std::endl;
|
||||
#endif
|
||||
mTurtle->stopMonitoringTunnels(it->second.tunnel_hash) ;
|
||||
|
||||
it->second.routing_flags &= ~GRouterRoutingInfo::ROUTING_FLAGS_ALLOW_TUNNELS ;
|
||||
it->second.tunnel_status = RS_GROUTER_TUNNEL_STATUS_UNMANAGED ;
|
||||
|
||||
//it->second.data_status = RS_GROUTER_DATA_STATUS_PENDING ;
|
||||
}
|
||||
#ifdef GROUTER_DEBUG
|
||||
else
|
||||
std::cerr << " doing nothing." << std::endl;
|
||||
{
|
||||
#ifdef GROUTER_DEBUG
|
||||
std::cerr << " closing pending tunnels." << std::endl;
|
||||
#endif
|
||||
mTurtle->stopMonitoringTunnels(it->second.tunnel_hash) ;
|
||||
|
||||
// also check that all tunnels are actually active, to remove any old dead tunnels
|
||||
//
|
||||
// if(it->second.tunnel_status == RS_GROUTER_TUNNEL_STATUS_READY)
|
||||
// {
|
||||
// std::map<TurtleFileHash,GRouterTunnelInfo>::iterator it2 = _tunnels.find(it->second.tunnel_hash) ;
|
||||
//
|
||||
// if(it2 == _tunnels.end() || it2->second.virtual_peers.empty()) ;
|
||||
// {
|
||||
// std::cerr << " re-setting tunnel status to PENDING, as no tunnels are actually present." << std::endl;
|
||||
// it->second.tunnel_status = RS_GROUTER_TUNNEL_STATUS_PENDING ;
|
||||
// }
|
||||
// }
|
||||
it->second.tunnel_status = RS_GROUTER_TUNNEL_STATUS_UNMANAGED ;
|
||||
}
|
||||
|
||||
// also check that all tunnels are actually active, to remove any old dead tunnels
|
||||
//
|
||||
// if(it->second.tunnel_status == RS_GROUTER_TUNNEL_STATUS_READY)
|
||||
// {
|
||||
// std::map<TurtleFileHash,GRouterTunnelInfo>::iterator it2 = _tunnels.find(it->second.tunnel_hash) ;
|
||||
//
|
||||
// if(it2 == _tunnels.end() || it2->second.virtual_peers.empty()) ;
|
||||
// {
|
||||
// std::cerr << " re-setting tunnel status to PENDING, as no tunnels are actually present." << std::endl;
|
||||
// it->second.tunnel_status = RS_GROUTER_TUNNEL_STATUS_PENDING ;
|
||||
// }
|
||||
// }
|
||||
}
|
||||
#ifdef GROUTER_DEBUG
|
||||
if(!priority_list.empty())
|
||||
@ -916,6 +894,7 @@ if(!_pending_messages.empty())
|
||||
|
||||
priority_list[i].second->tunnel_status = RS_GROUTER_TUNNEL_STATUS_PENDING ;
|
||||
priority_list[i].second->last_tunnel_request_TS = now ;
|
||||
priority_list[i].second->sending_attempts++ ;
|
||||
}
|
||||
}
|
||||
|
||||
@ -945,11 +924,10 @@ void p3GRouter::routePendingObjects()
|
||||
std::cerr << " message " << std::hex << it->first << std::dec << std::endl;
|
||||
#endif
|
||||
if(it->second.data_status == RS_GROUTER_DATA_STATUS_PENDING)
|
||||
{
|
||||
{
|
||||
// Look for tunnels and friends where to send the data. Send to both.
|
||||
|
||||
// Look for tunnels and friends where to send the data. Send to both.
|
||||
|
||||
std::list<RsPeerId> peers ;
|
||||
std::list<RsPeerId> peers ;
|
||||
|
||||
if(it->second.routing_flags & GRouterRoutingInfo::ROUTING_FLAGS_ALLOW_TUNNELS)
|
||||
locked_collectAvailableTunnels(it->second.tunnel_hash,peers);
|
||||
@ -965,8 +943,7 @@ void p3GRouter::routePendingObjects()
|
||||
std::cerr << " no direct friends available" << std::endl;
|
||||
#endif
|
||||
|
||||
if(it->second.received_time_TS + DIRECT_FRIEND_TRY_DELAY < now &&
|
||||
!(it->second.routing_flags & GRouterRoutingInfo::ROUTING_FLAGS_ALLOW_TUNNELS))
|
||||
if(it->second.received_time_TS + DIRECT_FRIEND_TRY_DELAY < now && !(it->second.routing_flags & GRouterRoutingInfo::ROUTING_FLAGS_ALLOW_TUNNELS))
|
||||
{
|
||||
#ifdef GROUTER_DEBUG
|
||||
std::cerr << " enabling tunnels for this message." << std::endl;
|
||||
@ -982,23 +959,23 @@ void p3GRouter::routePendingObjects()
|
||||
sliceDataItem(it->second.data_item,chunks) ;
|
||||
|
||||
#ifdef GROUTER_DEBUG
|
||||
if(!peers.empty())
|
||||
std::cerr << " sending to peers:" << std::endl;
|
||||
if(!peers.empty())
|
||||
std::cerr << " sending to peers:" << std::endl;
|
||||
#endif
|
||||
for(std::list<RsPeerId>::const_iterator itpid(peers.begin());itpid!=peers.end();++itpid)
|
||||
for(std::list<RsGRouterTransactionChunkItem*>::const_iterator it2(chunks.begin());it2!=chunks.end();++it2)
|
||||
locked_sendTransactionData(*itpid,*(*it2) ) ;
|
||||
for(std::list<RsPeerId>::const_iterator itpid(peers.begin());itpid!=peers.end();++itpid)
|
||||
for(std::list<RsGRouterTransactionChunkItem*>::const_iterator it2(chunks.begin());it2!=chunks.end();++it2)
|
||||
locked_sendTransactionData(*itpid,*(*it2) ) ;
|
||||
|
||||
// delete temporary items
|
||||
// delete temporary items
|
||||
|
||||
for(std::list<RsGRouterTransactionChunkItem*>::const_iterator cit=chunks.begin();cit!=chunks.end();++cit)
|
||||
delete *cit;
|
||||
for(std::list<RsGRouterTransactionChunkItem*>::const_iterator cit=chunks.begin();cit!=chunks.end();++cit)
|
||||
delete *cit;
|
||||
|
||||
// change item state in waiting list
|
||||
// change item state in waiting list
|
||||
|
||||
it->second.data_status = RS_GROUTER_DATA_STATUS_ONGOING ;
|
||||
it->second.data_transaction_TS = now ; ;
|
||||
}
|
||||
it->second.data_status = RS_GROUTER_DATA_STATUS_ONGOING ;
|
||||
it->second.data_transaction_TS = now ;
|
||||
}
|
||||
else if(it->second.data_status == RS_GROUTER_DATA_STATUS_ONGOING && now > MAX_TRANSACTION_ACK_WAITING_TIME + it->second.data_transaction_TS)
|
||||
{
|
||||
#ifdef GROUTER_DEBUG
|
||||
@ -1007,6 +984,23 @@ void p3GRouter::routePendingObjects()
|
||||
|
||||
it->second.data_status = RS_GROUTER_DATA_STATUS_PENDING ;
|
||||
}
|
||||
else if(it->second.data_status == RS_GROUTER_DATA_STATUS_SENT)
|
||||
{
|
||||
if( (it->second.routing_flags & GRouterRoutingInfo::ROUTING_FLAGS_IS_ORIGIN) && it->second.last_sent_TS + MAX_DELAY_FOR_RESEND < now)
|
||||
{
|
||||
#ifdef GROUTER_DEBUG
|
||||
std::cerr << " item was not received. Re-setting status to PENDING" << std::endl;
|
||||
#endif
|
||||
it->second.data_status = RS_GROUTER_DATA_STATUS_PENDING ;
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifdef GROUTER_DEBUG
|
||||
std::cerr << " item was sent. Desactivating tunnels." << std::endl;
|
||||
#endif
|
||||
it->second.routing_flags &= ~GRouterRoutingInfo::ROUTING_FLAGS_ALLOW_TUNNELS ;
|
||||
}
|
||||
}
|
||||
else if(it->second.data_status == RS_GROUTER_DATA_STATUS_RECEIPT_OK)
|
||||
{
|
||||
// send the receipt through all incoming routes, as soon as it gets delivered.
|
||||
@ -1435,31 +1429,31 @@ void p3GRouter::handleIncomingReceiptItem(RsGRouterSignedReceiptItem *receipt_it
|
||||
std::cerr << " removing messsage from cache." << std::endl;
|
||||
#endif
|
||||
|
||||
if(it->second.routing_flags & GRouterRoutingInfo::ROUTING_FLAGS_IS_ORIGIN)
|
||||
{
|
||||
if(it->second.routing_flags & GRouterRoutingInfo::ROUTING_FLAGS_IS_ORIGIN)
|
||||
{
|
||||
#ifdef GROUTER_DEBUG
|
||||
std::cerr << " message is at origin. Setting message transmission to DONE" << std::endl;
|
||||
std::cerr << " message is at origin. Setting message transmission to DONE" << std::endl;
|
||||
#endif
|
||||
it->second.data_status = RS_GROUTER_DATA_STATUS_DONE;
|
||||
it->second.data_status = RS_GROUTER_DATA_STATUS_DONE;
|
||||
|
||||
if(locked_getClientAndServiceId(it->second.tunnel_hash,it->second.data_item->destination_key,client_service,service_id))
|
||||
mid = it->first ;
|
||||
if(locked_getClientAndServiceId(it->second.tunnel_hash,it->second.data_item->destination_key,client_service,service_id))
|
||||
mid = it->first ;
|
||||
else
|
||||
{
|
||||
mid = 0 ;
|
||||
std::cerr << " ERROR: cannot retrieve service ID for message " << std::hex << it->first << std::dec << std::endl;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
mid = 0 ;
|
||||
std::cerr << " ERROR: cannot retrieve service ID for message " << std::hex << it->first << std::dec << std::endl;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifdef GROUTER_DEBUG
|
||||
std::cerr << " message is not at origin. Setting message transmission to RECEIPT_OK" << std::endl;
|
||||
std::cerr << " message is not at origin. Setting message transmission to RECEIPT_OK" << std::endl;
|
||||
#endif
|
||||
it->second.data_status = RS_GROUTER_DATA_STATUS_RECEIPT_OK;
|
||||
it->second.receipt_item = receipt_item->duplicate() ;
|
||||
}
|
||||
it->second.data_status = RS_GROUTER_DATA_STATUS_RECEIPT_OK;
|
||||
it->second.receipt_item = receipt_item->duplicate() ;
|
||||
}
|
||||
|
||||
changed = true ;
|
||||
changed = true ;
|
||||
}
|
||||
|
||||
if(mid != 0)
|
||||
@ -1470,6 +1464,16 @@ void p3GRouter::handleIncomingReceiptItem(RsGRouterSignedReceiptItem *receipt_it
|
||||
client_service->notifyDataStatus(mid, GROUTER_CLIENT_SERVICE_DATA_STATUS_RECEIVED) ;
|
||||
}
|
||||
|
||||
// also note the incoming route in the routing matrix
|
||||
|
||||
if(!mTurtle->isTurtlePeer(receipt_item->PeerId()))
|
||||
{
|
||||
#ifdef GROUTER_DEBUG
|
||||
std::cerr << " receipt item comes from a direct friend. Marking route in routing matrix." << std::endl;
|
||||
#endif
|
||||
addRoutingClue(receipt_item->signature.keyId,receipt_item->PeerId()) ;
|
||||
}
|
||||
|
||||
if(changed)
|
||||
IndicateConfigChanged() ;
|
||||
}
|
||||
@ -1603,8 +1607,7 @@ void p3GRouter::handleIncomingDataItem(RsGRouterGenericDataItem *data_item)
|
||||
info.data_item = data_item->duplicate() ;
|
||||
info.receipt_item = receipt_item ; // inited before, or NULL.
|
||||
info.tunnel_status = RS_GROUTER_TUNNEL_STATUS_UNMANAGED ;
|
||||
info.last_tunnel_sent_TS = 0 ;
|
||||
info.last_friend_sent_TS = 0 ;
|
||||
info.last_sent_TS = 0 ;
|
||||
info.item_hash = item_hash ;
|
||||
info.last_tunnel_request_TS = 0 ;
|
||||
info.sending_attempts = 0 ;
|
||||
@ -1925,8 +1928,7 @@ bool p3GRouter::sendData(const RsGxsId& destination,const GRouterServiceId& clie
|
||||
info.receipt_item = NULL ;
|
||||
info.data_status = RS_GROUTER_DATA_STATUS_PENDING ;
|
||||
info.tunnel_status = RS_GROUTER_TUNNEL_STATUS_UNMANAGED ;
|
||||
info.last_tunnel_sent_TS = 0 ;
|
||||
info.last_friend_sent_TS = 0 ;
|
||||
info.last_sent_TS = 0 ;
|
||||
info.last_tunnel_request_TS = 0 ;
|
||||
info.item_hash = computeDataItemHash(data_item) ;
|
||||
info.sending_attempts = 0 ;
|
||||
@ -2111,7 +2113,7 @@ bool p3GRouter::getRoutingCacheInfo(std::vector<GRouterRoutingCacheInfo>& infos)
|
||||
cinfo.destination = it->second.data_item->destination_key ;
|
||||
cinfo.routing_time = it->second.received_time_TS ;
|
||||
cinfo.last_tunnel_attempt_time = it->second.last_tunnel_request_TS ;
|
||||
cinfo.last_sent_time = std::max(it->second.last_tunnel_sent_TS,it->second.last_friend_sent_TS) ;
|
||||
cinfo.last_sent_time = it->second.last_sent_TS ;
|
||||
cinfo.receipt_available = (it->second.receipt_item != NULL);
|
||||
cinfo.data_status = it->second.data_status ;
|
||||
cinfo.tunnel_status = it->second.tunnel_status ;
|
||||
@ -2156,8 +2158,7 @@ void p3GRouter::debugDump()
|
||||
grouter_debug() << " data hash : " << it->second.item_hash ;
|
||||
grouter_debug() << " Destination : " << it->second.data_item->destination_key ;
|
||||
grouter_debug() << " Received : " << now - it->second.received_time_TS << " secs ago.";
|
||||
grouter_debug() << " Last tunnel sent: " << now - it->second.last_tunnel_sent_TS << " secs ago.";
|
||||
grouter_debug() << " Last friend sent: " << now - it->second.last_friend_sent_TS << " secs ago.";
|
||||
grouter_debug() << " Last sent : " << now - it->second.last_sent_TS << " secs ago.";
|
||||
grouter_debug() << " Transaction TS : " << now - it->second.data_transaction_TS << " secs ago.";
|
||||
grouter_debug() << " Data Status : " << statusString[it->second.data_status] << std::endl;
|
||||
grouter_debug() << " Tunl Status : " << statusString[it->second.tunnel_status] << std::endl;
|
||||
|
@ -402,9 +402,11 @@ HEADERS += grouter/groutercache.h \
|
||||
grouter/grouteritems.h \
|
||||
grouter/p3grouter.h \
|
||||
grouter/rsgroutermatrix.h \
|
||||
grouter/groutertypes.h \
|
||||
grouter/rsgrouterclient.h
|
||||
|
||||
HEADERS += serialiser/rsbaseserial.h \
|
||||
HEADERS += serialiser/itempriorities.h \
|
||||
serialiser/rsbaseserial.h \
|
||||
serialiser/rsfiletransferitems.h \
|
||||
serialiser/rsserviceserialiser.h \
|
||||
serialiser/rsconfigitems.h \
|
||||
|
Loading…
x
Reference in New Issue
Block a user