1- /*
2- This file is part of cpp-ethereum.
3-
4- cpp-ethereum is free software: you can redistribute it and/or modify
5- it under the terms of the GNU General Public License as published by
6- the Free Software Foundation, either version 3 of the License, or
7- (at your option) any later version.
8-
9- cpp-ethereum is distributed in the hope that it will be useful,
10- but WITHOUT ANY WARRANTY; without even the implied warranty of
11- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12- GNU General Public License for more details.
13-
14- You should have received a copy of the GNU General Public License
15- along with cpp-ethereum. If not, see <http://www.gnu.org/licenses/>.
16- */
1+ // Aleth: Ethereum C++ client, tools and libraries.
2+ // Copyright 2019 Aleth Authors.
3+ // Licensed under the GNU General Public License, Version 3.
174
185#include " EthereumPeer.h"
196#include < libethcore/Common.h>
@@ -24,10 +11,10 @@ using namespace std;
2411using namespace dev ;
2512using namespace dev ::eth;
2613
27- static std::string const c_ethCapability = " eth" ;
28-
2914namespace
3015{
16+ std::string const c_ethCapability = " eth" ;
17+
3118string toString (Asking _a)
3219{
3320 switch (_a)
@@ -67,17 +54,20 @@ void EthereumPeer::setStatus(unsigned _protocolVersion, u256 const& _networkId,
6754std::string EthereumPeer::validate (
6855 h256 const & _hostGenesisHash, unsigned _hostProtocolVersion, u256 const & _hostNetworkId) const
6956{
70- std::string error;
71- if (m_genesisHash != _hostGenesisHash)
72- error = " Invalid genesis hash." ;
57+ std::stringstream error;
58+ if (m_networkId != _hostNetworkId)
59+ error << " Network identifier mismatch. Host network id: " << _hostNetworkId
60+ << " , peer network id: " << m_networkId;
7361 else if (m_protocolVersion != _hostProtocolVersion)
74- error = " Invalid protocol version." ;
75- else if (m_networkId != _hostNetworkId)
76- error = " Invalid network identifier." ;
62+ error << " Protocol version mismatch. Host protocol version: " << _hostProtocolVersion
63+ << " , peer protocol version: " << m_protocolVersion;
64+ else if (m_genesisHash != _hostGenesisHash)
65+ error << " Genesis hash mismatch. Host genesis hash: " << _hostGenesisHash
66+ << " , peer genesis hash: " << m_genesisHash;
7767 else if (m_asking != Asking::State && m_asking != Asking::Nothing)
78- error = " Peer banned for unexpected status message." ;
68+ error << " Peer banned for unexpected status message." ;
7969
80- return error;
70+ return error. str () ;
8171}
8272
8373void EthereumPeer::requestStatus (
0 commit comments