public void run() { PeerDiscovery peerDiscovery = new DnsDiscovery(NetworkParameters.prodNet()); try { while (true) { InetSocketAddress addresses[] = peerDiscovery.getPeers(); // InetSocketAddress addresses[]={new InetSocketAddress("localhost",8333)}; System.out.println("peers " + addresses.length); NetworkConnection conn; Peer peer; System.out.println("connecting to peers"); for (InetSocketAddress a : addresses) { try { System.out.println("Trying " + a); conn = new NetworkConnection( a.getAddress(), Bitten.networkParameters, blockChain.getChainHead().getHeight(), 3000); System.out.println("after network connection"); peer = new Peer(Bitten.networkParameters, conn, blockChain); System.out.println("starting chain download"); peer.start(); peer.startBlockChainDownload(); while (true) { if (!peer.running()) { System.out.println("peer stopped!"); break; } sleep(1000); } } catch (IOException e) { System.out.println(e); continue; } catch (ProtocolException e) { continue; } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); continue; } } } } catch (PeerDiscoveryException e) { // TODO Auto-generated catch block e.printStackTrace(); } }