This repository has been archived by the owner on Oct 28, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Fix logic used to determine if Aleth should request dao fork block header from potential peer #5539
Merged
Merged
Changes from 3 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
b037fbe
Add check for infinite block number to dao check
halfalicious 841c7d8
Update license messages and add constexpr
halfalicious 37b2dc2
Fix misspelling in constant c_infiniteBlockNumer
halfalicious d70051b
Remove unnecessary static + switch constexpr/type
halfalicious a32de03
Update changelog
halfalicious File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,6 @@ | ||
/* | ||
This file is part of cpp-ethereum. | ||
|
||
cpp-ethereum is free software: you can redistribute it and/or modify | ||
it under the terms of the GNU General Public License as published by | ||
the Free Software Foundation, either version 3 of the License, or | ||
(at your option) any later version. | ||
|
||
cpp-ethereum is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU General Public License for more details. | ||
|
||
You should have received a copy of the GNU General Public License | ||
along with cpp-ethereum. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
/** @file BlockChainSync.cpp | ||
* @author Gav Wood <i@gavwood.com> | ||
* @date 2014 | ||
*/ | ||
/// Aleth: Ethereum C++ client, tools and libraries. | ||
// Copyright 2019 Aleth Authors. | ||
// Licensed under the GNU General Public License, Version 3. | ||
|
||
#include "BlockChainSync.h" | ||
|
||
|
@@ -35,11 +18,6 @@ using namespace std; | |
using namespace dev; | ||
using namespace dev::eth; | ||
|
||
unsigned const c_maxPeerUknownNewBlocks = 1024; /// Max number of unknown new blocks peer can give us | ||
unsigned const c_maxRequestHeaders = 1024; | ||
unsigned const c_maxRequestBodies = 1024; | ||
|
||
|
||
std::ostream& dev::eth::operator<<(std::ostream& _out, SyncStatus const& _sync) | ||
{ | ||
_out << "protocol: " << _sync.protocolVersion << endl; | ||
|
@@ -52,6 +30,10 @@ std::ostream& dev::eth::operator<<(std::ostream& _out, SyncStatus const& _sync) | |
namespace // Helper functions. | ||
{ | ||
|
||
unsigned constexpr c_maxPeerUknownNewBlocks = 1024; /// Max number of unknown new blocks peer can give us | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Pedantic mode: should be There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why do we put |
||
unsigned constexpr c_maxRequestHeaders = 1024; | ||
unsigned constexpr c_maxRequestBodies = 1024; | ||
|
||
template<typename T> bool haveItem(std::map<unsigned, T>& _container, unsigned _number) | ||
{ | ||
if (_container.empty()) | ||
|
@@ -230,8 +212,8 @@ void BlockChainSync::onPeerStatus(EthereumPeer const& _peer) | |
bool BlockChainSync::requestDaoForkBlockHeader(NodeID const& _peerID) | ||
{ | ||
// DAO challenge | ||
unsigned const daoHardfork = static_cast<unsigned>(host().chain().sealEngine()->chainParams().daoHardforkBlock); | ||
if (daoHardfork == 0) | ||
u256 const daoHardfork = host().chain().sealEngine()->chainParams().daoHardforkBlock; | ||
if (daoHardfork == 0 || daoHardfork == c_infiniteBlockNumber) | ||
return false; | ||
|
||
m_daoChallengedPeers.insert(_peerID); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
The
static
is redundant forconstexpr
.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.
I thought that
static
andconstexpr
are orthogonal concepts? I agree thatstatic
doesn't make sense here (regardless of the constexpr) since this is a header file andc_infiniteBlockNumber
is defined outside of a class - from what I understand, static when used this way limits the scope of the variable to the translation unit which means that each cpp file which includes the header will have a separate instance ofc_infiniteBlockNumber
(though each instance will have the same value) which seems unnecessary.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.
I'm also confused now. On the language level that might be true. But also
constexpr
impliesinline
andinline
impliesstatic
.I check than in practice the
constexpr
symbols are not exported.