Skip to content

Commit d780293

Browse files
jonatackjnewbery
andcommitted
net: improve nLastBlockTime and nLastTXTime documentation
Co-authored-by: John Newbery <[email protected]>
1 parent bab4cce commit d780293

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

src/net.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -904,10 +904,10 @@ bool CConnman::AttemptToEvictConnection()
904904
// Protect the 8 nodes with the lowest minimum ping time.
905905
// An attacker cannot manipulate this metric without physically moving nodes closer to the target.
906906
EraseLastKElements(vEvictionCandidates, ReverseCompareNodeMinPingTime, 8);
907-
// Protect 4 nodes that most recently sent us transactions.
907+
// Protect 4 nodes that most recently sent us novel transactions accepted into our mempool.
908908
// An attacker cannot manipulate this metric without performing useful work.
909909
EraseLastKElements(vEvictionCandidates, CompareNodeTXTime, 4);
910-
// Protect 4 nodes that most recently sent us blocks.
910+
// Protect 4 nodes that most recently sent us novel blocks.
911911
// An attacker cannot manipulate this metric without performing useful work.
912912
EraseLastKElements(vEvictionCandidates, CompareNodeBlockTime, 4);
913913
// Protect the half of the remaining nodes which have been connected the longest.

src/net.h

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -932,8 +932,17 @@ class CNode
932932
// Used for headers announcements - unfiltered blocks to relay
933933
std::vector<uint256> vBlockHashesToAnnounce GUARDED_BY(cs_inventory);
934934

935-
// Block and TXN accept times
935+
/** UNIX epoch time of the last block received from this peer that we had
936+
* not yet seen (e.g. not already received from another peer), that passed
937+
* preliminary validity checks and was saved to disk, even if we don't
938+
* connect the block or it eventually fails connection. Used as an inbound
939+
* peer eviction criterium in CConnman::AttemptToEvictConnection. */
936940
std::atomic<int64_t> nLastBlockTime{0};
941+
942+
/** UNIX epoch time of the last transaction received from this peer that we
943+
* had not yet seen (e.g. not already received from another peer) and that
944+
* was accepted into our mempool. Used as an inbound peer eviction criterium
945+
* in CConnman::AttemptToEvictConnection. */
937946
std::atomic<int64_t> nLastTXTime{0};
938947

939948
// Ping time measurement:

0 commit comments

Comments
 (0)