mirror of
https://github.com/Qortal/altcoinj.git
synced 2025-02-07 06:44:16 +00:00
Fix lock inversion.
This commit is contained in:
parent
b71015a297
commit
eb7c4be136
@ -1098,17 +1098,19 @@ public class PeerGroup extends AbstractIdleService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Given a list of Peers, return a Peer to be used as the download peer. */
|
/** Given a list of Peers, return a Peer to be used as the download peer. */
|
||||||
protected Peer selectDownloadPeer(List<Peer> peers) {
|
protected Peer selectDownloadPeer(List<Peer> origPeers) {
|
||||||
synchronized (peers) {
|
List<Peer> peers;
|
||||||
if (peers.isEmpty())
|
synchronized (origPeers) {
|
||||||
return null;
|
peers = new ArrayList<Peer>(origPeers);
|
||||||
// Make sure we don't select a peer that is behind/synchronizing itself.
|
|
||||||
int mostCommonChainHeight = getMostCommonChainHeight();
|
|
||||||
for (Peer peer : peers) {
|
|
||||||
if (peer.getBestHeight() == mostCommonChainHeight) return peer;
|
|
||||||
}
|
|
||||||
throw new IllegalStateException("Unreachable");
|
|
||||||
}
|
}
|
||||||
|
if (peers.isEmpty())
|
||||||
|
return null;
|
||||||
|
// Make sure we don't select a peer that is behind/synchronizing itself.
|
||||||
|
int mostCommonChainHeight = getMostCommonChainHeight();
|
||||||
|
for (Peer peer : peers) {
|
||||||
|
if (peer.getBestHeight() == mostCommonChainHeight) return peer;
|
||||||
|
}
|
||||||
|
throw new IllegalStateException("Unreachable");
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class PeerGroupThreadFactory implements ThreadFactory {
|
private static class PeerGroupThreadFactory implements ThreadFactory {
|
||||||
|
Loading…
Reference in New Issue
Block a user