Skip to content

Commit

Permalink
v2: overlook old interests within RTT (close #25)
Browse files Browse the repository at this point in the history
  • Loading branch information
pulsejet committed Dec 19, 2023
1 parent f998c2b commit ad72811
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
4 changes: 4 additions & 0 deletions ndn-svs/core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,10 @@ SVSyncCore::mergeStateVector(const VersionVector& vvOther)
SeqNo seq = entry.second;
SeqNo seqOther = vvOther.get(nid);

// Ignore this node if it was last updated within network RTT
if (time::system_clock::now() - m_vv.getLastUpdate(nid) < m_maxSuppressionTime)
continue;

if (seqOther < seq)
{
myVectorNew = true;
Expand Down
9 changes: 9 additions & 0 deletions ndn-svs/version-vector.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ class VersionVector
set(const NodeID& nid, SeqNo seqNo)
{
m_map[nid] = seqNo;
m_lastUpdate[nid] = time::system_clock::now();
return seqNo;
}

Expand All @@ -62,6 +63,13 @@ class VersionVector
return elem == m_map.end() ? 0 : elem->second;
}

time::system_clock::time_point
getLastUpdate(const NodeID& nid) const
{
auto elem = m_lastUpdate.find(nid);
return elem == m_lastUpdate.end() ? time::system_clock::time_point::min() : elem->second;
}

const_iterator
begin() const noexcept
{
Expand All @@ -82,6 +90,7 @@ class VersionVector

private:
std::map<NodeID, SeqNo> m_map;
std::map<NodeID, time::system_clock::time_point> m_lastUpdate;
};

} // namespace ndn::svs
Expand Down

0 comments on commit ad72811

Please sign in to comment.