mirror of
https://github.com/ElementsProject/elements.git
synced 2026-08-14 12:43:40 +02:00
Merge 3c13f5d612 into merged_master (Bitcoin PR bitcoin/bitcoin#28956)
This commit is contained in:
commit
b15f9acb3d
15 changed files with 17 additions and 32 deletions
|
|
@ -1341,7 +1341,7 @@ bool PeerManagerImpl::CanDirectFetch()
|
|||
LogPrint(BCLog::NET, "Tried to call CanDirectFetch with no currently-active chain.\n");
|
||||
return false;
|
||||
}
|
||||
return m_chainman.ActiveChain().Tip()->Time() > GetAdjustedTime() - m_chainparams.GetConsensus().PowTargetSpacing() * 20;
|
||||
return m_chainman.ActiveChain().Tip()->Time() > NodeClock::now() - m_chainparams.GetConsensus().PowTargetSpacing() * 20;
|
||||
}
|
||||
|
||||
static bool PeerHasHeader(CNodeState *state, const CBlockIndex *pindex) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
|
||||
|
|
@ -5671,7 +5671,7 @@ bool PeerManagerImpl::SendMessages(CNode* pto)
|
|||
bool got_enough_headers = node::fTrimHeaders && (headers_ahead >= node::nHeaderDownloadBuffer);
|
||||
if (!state.fSyncStarted && CanServeBlocks(*peer) && !m_chainman.m_blockman.LoadingBlocks() && !got_enough_headers) {
|
||||
// Only actively request headers from a single peer, unless we're close to today.
|
||||
if ((nSyncStarted == 0 && sync_blocks_and_headers_from_peer) || m_chainman.m_best_header->Time() > GetAdjustedTime() - 24h) {
|
||||
if ((nSyncStarted == 0 && sync_blocks_and_headers_from_peer) || m_chainman.m_best_header->Time() > NodeClock::now() - 24h) {
|
||||
const CBlockIndex* pindexStart = m_chainman.m_best_header;
|
||||
/* If possible, start at the block preceding the currently
|
||||
best known header. This ensures that we always get a
|
||||
|
|
@ -5691,7 +5691,7 @@ bool PeerManagerImpl::SendMessages(CNode* pto)
|
|||
// Convert HEADERS_DOWNLOAD_TIMEOUT_PER_HEADER to microseconds before scaling
|
||||
// to maintain precision
|
||||
std::chrono::microseconds{HEADERS_DOWNLOAD_TIMEOUT_PER_HEADER} *
|
||||
Ticks<std::chrono::seconds>(GetAdjustedTime() - m_chainman.m_best_header->Time()) / consensusParams.nPowTargetSpacing
|
||||
Ticks<std::chrono::seconds>(NodeClock::now() - m_chainman.m_best_header->Time()) / consensusParams.nPowTargetSpacing
|
||||
);
|
||||
nSyncStarted++;
|
||||
}
|
||||
|
|
@ -5997,7 +5997,7 @@ bool PeerManagerImpl::SendMessages(CNode* pto)
|
|||
// Check for headers sync timeouts
|
||||
if (state.fSyncStarted && peer->m_headers_sync_timeout < std::chrono::microseconds::max()) {
|
||||
// Detect whether this is a stalling initial-headers-sync peer
|
||||
if (m_chainman.m_best_header->Time() <= GetAdjustedTime() - 24h) {
|
||||
if (m_chainman.m_best_header->Time() <= NodeClock::now() - 24h) {
|
||||
if (current_time > peer->m_headers_sync_timeout && nSyncStarted == 1 && (m_num_preferred_download_peers - state.fPreferredDownload >= 1)) {
|
||||
// Disconnect a peer (without NetPermissionFlags::NoBan permission) if it is our only sync peer,
|
||||
// and we have others we could be using instead.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue