-
Notifications
You must be signed in to change notification settings - Fork 787
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Peer cache #4574
Peer cache #4574
Conversation
a4f2164
to
efe4369
Compare
@@ -4,12 +4,25 @@ | |||
nano::store::lmdb::peer::peer (nano::store::lmdb::component & store) : | |||
store{ store } {}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
spurious semicolon
lesser point: the braces placement looks a bit strange stylistically
Should
@gr0vity-dev heads-up: this might affect your scripts, I think you interact directly with the peers table, right? |
Thanks for the heads-up. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks like a good cleanup.
Only thing I noticed was on naming, is this really a cache? Maybe peer_history?
Not a blocker.
We do not really need to store the timestamp into the database, it can be kept in RAM only. |
I think we should be storing the peer node ID in the peer database too. |
nano/node/network.cpp
Outdated
} | ||
lock.unlock (); | ||
|
||
node.stats.inc (nano::stat::type::network, nano::stat::detail::loop_reachout); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this counter be loop_reachout_cached?
# Conflicts: # nano/lib/thread_roles.cpp # nano/lib/thread_roles.hpp
I fixed a few minor issues pointed by the review and renamed class to |
This introduces a new
peer_cache
component that is responsible for managing cached peers. Previously storing peers was done bytcp_channels
and loading bynode
, which is not the core responsibility of these classes.Previous behavior was that only the latest set of peers was stored (ie. cache was cleared before every write). Now the cache keeps track of peers up to a certain cutoff age (by default 1 hour).
Another behavior change is that network reachout thread tries to contact cached peers. Previously this was only done once, on node startup. This should help with resiliency if for some reason node temporarily loses connection to its peers (eg. due to network outage).