Skip to content
Snippets Groups Projects
Commit 6ae5df32 authored by Benoit Lavenier's avatar Benoit Lavenier
Browse files

[fix] Fix NullPointerException whencomputing buid on peer.stats without block number

parent 4d06518c
No related branches found
No related tags found
No related merge requests found
Pipeline #4308 passed
...@@ -236,10 +236,12 @@ public class NetworkServiceImpl extends BaseRemoteServiceImpl implements Network ...@@ -236,10 +236,12 @@ public class NetworkServiceImpl extends BaseRemoteServiceImpl implements Network
} }
public List<Peer> fillPeerStatsConsensus(final List<Peer> peers) { public List<Peer> fillPeerStatsConsensus(final List<Peer> peers) {
if (CollectionUtils.isEmpty(peers)) return peers;
final Map<String,Long> peerCountByBuid = peers.stream() final Map<String,Long> peerCountByBuid = peers.stream()
.filter(peer -> peer.getStats().isReacheable() && Peers.hasBmaEndpoint(peer)) .filter(peer -> peer.getStats() != null && peer.getStats().isReacheable() && Peers.hasBmaEndpoint(peer))
.map(Peers::buid) .map(Peers::buid)
.filter(b -> b != null)
.collect(Collectors.groupingBy(Function.identity(), Collectors.counting())); .collect(Collectors.groupingBy(Function.identity(), Collectors.counting()));
// Compute main consensus buid // Compute main consensus buid
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment