3
0
mirror of https://github.com/Qortal/altcoinj.git synced 2025-01-31 23:32:16 +00:00

PeerGroup: Remove a now-useless synchronized block and mark a few more fields final.

This commit is contained in:
Mike Hearn 2013-03-11 15:48:46 +01:00
parent a6d0c9169b
commit c351df567e

View File

@ -75,12 +75,12 @@ public class PeerGroup extends AbstractIdleService {
// These lists are all thread-safe so do not have to be accessed under the PeerGroup lock. // These lists are all thread-safe so do not have to be accessed under the PeerGroup lock.
// Addresses to try to connect to, excluding active peers. // Addresses to try to connect to, excluding active peers.
private List<PeerAddress> inactives; private final List<PeerAddress> inactives;
// Currently active peers. This is an ordered list rather than a set to make unit tests predictable. // Currently active peers. This is an ordered list rather than a set to make unit tests predictable.
private List<Peer> peers; private final List<Peer> peers;
// Currently connecting peers. // Currently connecting peers.
private List<Peer> pendingPeers; private final List<Peer> pendingPeers;
private ChannelGroup channels; private final ChannelGroup channels;
// The peer that has been selected for the purposes of downloading announced data. // The peer that has been selected for the purposes of downloading announced data.
private Peer downloadPeer; private Peer downloadPeer;
@ -132,7 +132,7 @@ public class PeerGroup extends AbstractIdleService {
lock.unlock(); lock.unlock();
} }
} }
};; };
private class PeerStartupListener implements Peer.PeerLifecycleListener { private class PeerStartupListener implements Peer.PeerLifecycleListener {
public void onPeerConnected(Peer peer) { public void onPeerConnected(Peer peer) {
@ -333,13 +333,11 @@ public class PeerGroup extends AbstractIdleService {
} else { } else {
// Check the wallets. // Check the wallets.
for (Wallet w : wallets) { for (Wallet w : wallets) {
synchronized (w) { tx = w.getTransaction(item.hash);
tx = w.getTransaction(item.hash); if (tx == null) continue;
if (tx == null) continue; transactions.add(tx);
transactions.add(tx); it.remove();
it.remove(); break;
break;
}
} }
} }
} }
@ -510,8 +508,7 @@ public class PeerGroup extends AbstractIdleService {
for (PeerDiscovery peerDiscovery : peerDiscoverers) { for (PeerDiscovery peerDiscovery : peerDiscoverers) {
InetSocketAddress[] addresses; InetSocketAddress[] addresses;
addresses = peerDiscovery.getPeers(10, TimeUnit.SECONDS); addresses = peerDiscovery.getPeers(10, TimeUnit.SECONDS);
for (int i = 0; i < addresses.length; i++) for (InetSocketAddress address : addresses) addressSet.add(new PeerAddress(address));
addressSet.add(new PeerAddress(addresses[i]));
if (addressSet.size() > 0) break; if (addressSet.size() > 0) break;
} }
synchronized (inactives) { synchronized (inactives) {