Skip to content
This repository has been archived by the owner on Oct 28, 2021. It is now read-only.

Commit

Permalink
Fix segmentation fault during syncing (#5834)
Browse files Browse the repository at this point in the history
Fix segmentation fault during syncing
  • Loading branch information
gumb0 authored Nov 20, 2019
2 parents fa45a92 + d298fa2 commit b148754
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
- Fixed: [#5821](https://github.com/ethereum/aleth/pull/5821) `test_setChainParams` correctly initializes custom configuration of precompiled contracts.
- Fixed: [#5826](https://github.com/ethereum/aleth/pull/5826) Fix blocking bug in database rebuild functionality - users can now rebuild their databases via Aleth's '-R' switch.
- Fixed: [#5827](https://github.com/ethereum/aleth/pull/5827) Detect database upgrades and automatically rebuild the database when they occur.
- Fixed: [#5834](https://github.com/ethereum/aleth/pull/5834) Fix segmentation fault during sync.

## [1.7.1] - 2019-11-18

Expand Down
16 changes: 8 additions & 8 deletions libethereum/EthereumCapability.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -629,8 +629,8 @@ void EthereumCapability::onDisconnect(NodeID const& _peerID)
bool EthereumCapability::interpretCapabilityPacket(
NodeID const& _peerID, unsigned _id, RLP const& _r)
{
auto& peer = m_peers[_peerID];
peer.setLastAsk(std::chrono::system_clock::to_time_t(chrono::system_clock::now()));
auto& remotePeer = peer(_peerID);
remotePeer.setLastAsk(std::chrono::system_clock::to_time_t(chrono::system_clock::now()));

try
{
Expand All @@ -648,10 +648,10 @@ bool EthereumCapability::interpretCapabilityPacket(
<< networkId << " / " << genesisHash << ", TD: " << totalDifficulty
<< " = " << latestHash;

peer.setStatus(
remotePeer.setStatus(
peerProtocolVersion, networkId, totalDifficulty, latestHash, genesisHash);
setIdle(_peerID);
m_peerObserver->onPeerStatus(peer);
m_peerObserver->onPeerStatus(remotePeer);
break;
}
case TransactionsPacket:
Expand Down Expand Up @@ -691,7 +691,7 @@ bool EthereumCapability::interpretCapabilityPacket(
}
case BlockHeadersPacket:
{
if (peer.asking() != Asking::BlockHeaders)
if (remotePeer.asking() != Asking::BlockHeaders)
LOG(m_loggerImpolite) << "Peer " << _peerID
<< " giving us block headers when we didn't ask for them.";
else
Expand Down Expand Up @@ -724,7 +724,7 @@ bool EthereumCapability::interpretCapabilityPacket(
}
case BlockBodiesPacket:
{
if (peer.asking() != Asking::BlockBodies)
if (remotePeer.asking() != Asking::BlockBodies)
LOG(m_loggerImpolite)
<< "Peer " << _peerID << " giving us block bodies when we didn't ask for them.";
else
Expand Down Expand Up @@ -803,7 +803,7 @@ bool EthereumCapability::interpretCapabilityPacket(
}
case NodeDataPacket:
{
if (peer.asking() != Asking::NodeData)
if (remotePeer.asking() != Asking::NodeData)
LOG(m_loggerImpolite)
<< "Peer " << _peerID << " giving us node data when we didn't ask for them.";
else
Expand All @@ -815,7 +815,7 @@ bool EthereumCapability::interpretCapabilityPacket(
}
case ReceiptsPacket:
{
if (peer.asking() != Asking::Receipts)
if (remotePeer.asking() != Asking::Receipts)
LOG(m_loggerImpolite)
<< "Peer " << _peerID << " giving us receipts when we didn't ask for them.";
else
Expand Down
2 changes: 1 addition & 1 deletion libethereum/EthereumPeer.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ namespace eth
class EthereumPeer
{
public:
EthereumPeer() = default;
EthereumPeer() = delete;
EthereumPeer(std::shared_ptr<p2p::CapabilityHostFace> _host, NodeID const& _peerID,
u256 const& /*_capabilityVersion*/)
: m_host(std::move(_host)), m_id(_peerID)
Expand Down

0 comments on commit b148754

Please sign in to comment.