Skip to content

Commit c17a003

Browse files
committed
Merge #19857: net: improve nLastBlockTime and nLastTXTime documentation
d780293 net: improve nLastBlockTime and nLastTXTime documentation (Jon Atack) Pull request description: Follow-up to #19731 to help alleviate confusion around `nLastBlockTime` and `nLastTXTime`, now also provided by the JSON-RPC API as `last_block` and `last_transaction` in `getpeerinfo` output. Thanks to John Newbery, credited in the commit, and to Dave Harding and Adam Jonas during discussions on how to best explain these in this week's Optech newsletter. ACKs for top commit: practicalswift: ACK d780293 MarcoFalke: ACK d780293 harding: ACK d780293 . The added documentation matches my reading of the code and answers a question I had after seeing #19731 0xB10C: ACK d780293 Tree-SHA512: 72d47cf50a099913c7e4753cb80e11785b26fb66fa3a8b6c382fde4ea725116f3d215f93d32a567246d269768e66159f8dcf017a1bbc6d5f2489a35f81c316fa
2 parents 505b39e + d780293 commit c17a003

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)