Send path simplification.

This commit is contained in:
Adam Ierymenko 2015-04-03 13:14:37 -07:00
parent a69e1876f1
commit ee0f56355b
10 changed files with 99 additions and 122 deletions

View file

@ -43,7 +43,6 @@ Peer::Peer(const Identity &myIdentity,const Identity &peerIdentity)
_lastUnicastFrame(0),
_lastMulticastFrame(0),
_lastAnnouncedTo(0),
_lastSpammed(0),
_vMajor(0),
_vMinor(0),
_vRevision(0),
@ -147,31 +146,6 @@ void Peer::received(
_lastMulticastFrame = now;
}
bool Peer::send(const RuntimeEnvironment *RR,const void *data,unsigned int len,uint64_t now)
{
Path *bestPath = (Path *)0;
uint64_t lrMax = 0;
for(unsigned int p=0,np=_numPaths;p<np;++p) {
if ((_paths[p].active(now)&&(_paths[p].lastReceived() >= lrMax)) {
lrMax = _paths[p].lastReceived();
bestPath = &(_paths[p]);
}
}
if (bestPath) {
bool spam = ((now - _lastSpammed) >= ZT_DESPERATION_SPAM_INTERVAL);
if (RR->node->putPacket(bestPath->address(),data,len,bestPath->desperation(),spam)) {
bestPath->sent(now);
RR->antiRec->logOutgoingZT(data,len);
if (spam)
_lastSpammed = now;
return true;
}
}
return false;
}
void Peer::addPath(const Path &newp)
{
unsigned int np = _numPaths;