From d9006712f6ffc975d97097caf2d2b4264405b32c Mon Sep 17 00:00:00 2001 From: Adam Ierymenko Date: Thu, 21 May 2015 15:58:26 -0700 Subject: Completely factor out "desperation" from the core. I thought of a significantly simpler way to move all of this logic entirely into the containing service, liberating the core from any concern over the nature of its pipe to the outside world. --- node/Switch.hpp | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) (limited to 'node/Switch.hpp') diff --git a/node/Switch.hpp b/node/Switch.hpp index aec7f046..0b748247 100644 --- a/node/Switch.hpp +++ b/node/Switch.hpp @@ -79,11 +79,10 @@ public: * Called when a packet is received from the real network * * @param fromAddr Internet IP address of origin - * @param linkDesperation Link desperation of path over which packet was received * @param data Packet data * @param len Packet length */ - void onRemotePacket(const InetAddress &fromAddr,int linkDesperation,const void *data,unsigned int len); + void onRemotePacket(const InetAddress &fromAddr,const void *data,unsigned int len); /** * Called when a packet comes from a local Ethernet tap @@ -136,9 +135,8 @@ public: * * @param peer Peer to contact * @param atAddr Address of peer - * @param linkDesperation Attempt up to given max desperation */ - void contact(const SharedPtr &peer,const InetAddress &atAddr,unsigned int maxDesperation); + void contact(const SharedPtr &peer,const InetAddress &atAddr); /** * Request WHOIS on a given address @@ -182,9 +180,9 @@ public: throw(); private: - void _handleRemotePacketFragment(const InetAddress &fromAddr,int linkDesperation,const void *data,unsigned int len); - void _handleRemotePacketHead(const InetAddress &fromAddr,int linkDesperation,const void *data,unsigned int len); - void _handleBeacon(const InetAddress &fromAddr,int linkDesperation,const Buffer &data); + void _handleRemotePacketFragment(const InetAddress &fromAddr,const void *data,unsigned int len); + void _handleRemotePacketHead(const InetAddress &fromAddr,const void *data,unsigned int len); + void _handleBeacon(const InetAddress &fromAddr,const Buffer &data); Address _sendWhoisRequest( const Address &addr, @@ -248,19 +246,15 @@ private: struct ContactQueueEntry { ContactQueueEntry() {} - ContactQueueEntry(const SharedPtr &p,uint64_t ft,const InetAddress &a,unsigned int md) : + ContactQueueEntry(const SharedPtr &p,uint64_t ft,const InetAddress &a) : peer(p), fireAtTime(ft), inaddr(a), - maxDesperation(md), - currentDesperation(0), - strategyIteration(1) {} // start with 2nd strategy, zero desperation, since we've already tried 0/0 + strategyIteration(1) {} // start with 2nd strategy, since first was tried at inception SharedPtr peer; uint64_t fireAtTime; InetAddress inaddr; - unsigned int maxDesperation; - unsigned int currentDesperation; unsigned int strategyIteration; }; std::list _contactQueue; -- cgit v1.2.3