/** Does a blocking stop */ public void stop() { try { stopAsync(); log.info("Awaiting PeerGroup shutdown ..."); executor.awaitTermination(Long.MAX_VALUE, TimeUnit.SECONDS); } catch (InterruptedException e) { throw new RuntimeException(e); } }
/** Does a blocking stop */ public void stop() { try { stopAsync(); log.info("Awaiting PeerGroup shutdown ..."); executor.awaitTermination(Long.MAX_VALUE, TimeUnit.SECONDS); } catch (InterruptedException e) { throw new RuntimeException(e); } }
/** Does a blocking stop */ public void stop() { try { stopAsync(); log.info("Awaiting PeerGroup shutdown ..."); executor.awaitTermination(Long.MAX_VALUE, TimeUnit.SECONDS); } catch (InterruptedException e) { throw new RuntimeException(e); } }
/** Does a blocking stop */ public void stop() { try { stopAsync(); log.info("Awaiting PeerGroup shutdown ..."); executor.awaitTermination(Long.MAX_VALUE, TimeUnit.SECONDS); } catch (InterruptedException e) { throw new RuntimeException(e); } }
/** * <p>Stops the current peer group blocking until completeWithoutSigning</p> */ private void stopPeerGroup() { if (peerGroup != null) { log.debug("Stopping peerGroup service..."); peerGroup.removeEventListener(peerEventListener); peerEventListener = null; // Remove the wallet from the peer group if (WalletManager.INSTANCE.getCurrentWalletSummary().isPresent()) { peerGroup.removeWallet(WalletManager.INSTANCE.getCurrentWalletSummary().get().getWallet()); } peerGroup.stopAsync(); log.debug("Service peerGroup stopped"); } else { log.debug("Peer group was not present"); } peerGroup = null; }
private void shutdown() { Log.d(TAG, "shutdown: "); peerGroup.removeWallet(wallet); peerGroup.stopAsync(); peerGroup.removeConnectedEventListener(mPeerConnectedEventListener); peerGroup.removeDisconnectedEventListener(mPeerDisconnectedEventListener); peerGroup.removeDiscoveredEventListener(mPeerDiscoveredEventListener); peerGroup = null; }
public static void main(String[] args) throws Exception { BriefLogFormatter.init(); System.out.println("Connecting to node"); final NetworkParameters params = TestNet3Params.get(); BlockStore blockStore = new MemoryBlockStore(params); BlockChain chain = new BlockChain(params, blockStore); PeerGroup peerGroup = new PeerGroup(params, chain); peerGroup.start(); PeerAddress addr = new PeerAddress(InetAddress.getLocalHost(), params.getPort()); peerGroup.addAddress(addr); peerGroup.waitForPeers(1).get(); Peer peer = peerGroup.getConnectedPeers().get(0); Sha256Hash blockHash = Sha256Hash.wrap(args[0]); Future<Block> future = peer.getBlock(blockHash); System.out.println("Waiting for node to send us the requested block: " + blockHash); Block block = future.get(); System.out.println(block); peerGroup.stopAsync(); } }
@Override public void tearDown() { try { super.tearDown(); blockJobs = false; Utils.finishMockSleep(); if (peerGroup.isRunning()) peerGroup.stopAsync(); } catch (Exception e) { throw new RuntimeException(e); } }
public static void main(String[] args) throws Exception { File file = new File(args[0]); Wallet wallet = Wallet.loadFromFile(file); System.out.println(wallet.toString()); // Set up the components and link them together. final NetworkParameters params = TestNet3Params.get(); BlockStore blockStore = new MemoryBlockStore(params); BlockChain chain = new BlockChain(params, wallet, blockStore); final PeerGroup peerGroup = new PeerGroup(params, chain); peerGroup.startAsync(); wallet.addCoinsReceivedEventListener(new WalletCoinsReceivedEventListener() { @Override public synchronized void onCoinsReceived(Wallet w, Transaction tx, Coin prevBalance, Coin newBalance) { System.out.println("\nReceived tx " + tx.getHashAsString()); System.out.println(tx.toString()); } }); // Now download and process the block chain. peerGroup.downloadBlockChain(); peerGroup.stopAsync(); wallet.saveToFile(file); System.out.println("\nDone!\n"); System.out.println(wallet.toString()); } }
peerGroup.startAsync(); peerGroup.downloadBlockChain(); peerGroup.stopAsync();