diff options
Diffstat (limited to 'src/main.cpp')
| -rw-r--r-- | src/main.cpp | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/main.cpp b/src/main.cpp index 9ab1f44..be89416 100644 --- a/src/main.cpp +++ b/src/main.cpp | |||
| @@ -101,6 +101,29 @@ static const int BLOCK_FETCH_TRACK_MAX = 8; | |||
| 101 | // forever; a re-announcement recreates it. | 101 | // forever; a re-announcement recreates it. |
| 102 | static const int BLOCK_FETCH_GIVEUP_SECS = 10 * 60; | 102 | static const int BLOCK_FETCH_GIVEUP_SECS = 10 * 60; |
| 103 | 103 | ||
| 104 | // How stale our own best block may be before we stop calling this the tip. | ||
| 105 | // Blocks target two minutes, so this is thirty intervals: far longer than any | ||
| 106 | // stall worth failing over from -- the one in #33 ran sixteen minutes -- and | ||
| 107 | // far shorter than catching up, which starts hours or days back. | ||
| 108 | static const int BLOCK_FETCH_TIP_AGE_SECS = 60 * 60; | ||
| 109 | |||
| 110 | // Whether this node is tracking the tip rather than still catching up. | ||
| 111 | // | ||
| 112 | // Measured off the age of our own best block, not off any height a peer told | ||
| 113 | // us. nStartingHeight is optional in the version message and every node | ||
| 114 | // released so far sends the short form, so it is -1 for essentially every | ||
| 115 | // peer; and where it is filled in later it is filled in from the height of a | ||
| 116 | // block that peer served us, which during catch-up tracks our own height and | ||
| 117 | // would report "at the tip" for the whole download. Block timestamps are the | ||
| 118 | // one clock here that peers cannot move: CheckBlock refuses anything more than | ||
| 119 | // two hours ahead and AcceptBlock refuses anything at or before the previous | ||
| 120 | // median, so the only way to make this read "at the tip" falsely is to mine, | ||
| 121 | // and all that buys is the 15s spacing this code had unconditionally anyway. | ||
| 122 | bool IsBlockFetchNearTip() | ||
| 123 | { | ||
| 124 | return pindexBest && (int64)pindexBest->nTime > GetTime() - BLOCK_FETCH_TIP_AGE_SECS; | ||
| 125 | } | ||
| 126 | |||
| 104 | // Drop one entry so a hash announced by addrNew can be tracked. | 127 | // Drop one entry so a hash announced by addrNew can be tracked. |
| 105 | // | 128 | // |
| 106 | // Refusing the insertion instead was a remote off-switch for the whole | 129 | // Refusing the insertion instead was a remote off-switch for the whole |