Peer extends PeerSocketHandler { public void addConnectedEventListener(PeerConnectedEventListener listener) { addConnectedEventListener(Threading.USER_THREAD, listener); } Peer(NetworkParameters params, VersionMessage ver, @Nullable AbstractBlockChain chain, PeerAddress remoteAddress);  Peer(NetworkParameters params, VersionMessage ver, PeerAddress remoteAddress,
                @Nullable AbstractBlockChain chain);  Peer(NetworkParameters params, VersionMessage ver, PeerAddress remoteAddress,
                @Nullable AbstractBlockChain chain, int downloadTxDependencyDepth);  Peer(NetworkParameters params, AbstractBlockChain blockChain, PeerAddress peerAddress, String thisSoftwareName, String thisSoftwareVersion); @Deprecated @SuppressWarnings("deprecation") void addEventListener(AbstractPeerEventListener listener); @Deprecated void addEventListener(AbstractPeerEventListener listener, Executor executor); @Deprecated void removeEventListener(AbstractPeerEventListener listener); void addBlocksDownloadedEventListener(BlocksDownloadedEventListener listener); void addBlocksDownloadedEventListener(Executor executor, BlocksDownloadedEventListener listener); void addChainDownloadStartedEventListener(ChainDownloadStartedEventListener listener); void addChainDownloadStartedEventListener(Executor executor, ChainDownloadStartedEventListener listener); void addConnectedEventListener(PeerConnectedEventListener listener); void addConnectedEventListener(Executor executor, PeerConnectedEventListener listener); void addDisconnectedEventListener(PeerDisconnectedEventListener listener); void addDisconnectedEventListener(Executor executor, PeerDisconnectedEventListener listener); void addGetDataEventListener(GetDataEventListener listener); void addGetDataEventListener(Executor executor, GetDataEventListener listener); void addOnTransactionBroadcastListener(OnTransactionBroadcastListener listener); void addOnTransactionBroadcastListener(Executor executor, OnTransactionBroadcastListener listener); void addPreMessageReceivedEventListener(PreMessageReceivedEventListener listener); void addPreMessageReceivedEventListener(Executor executor, PreMessageReceivedEventListener listener); boolean removeBlocksDownloadedEventListener(BlocksDownloadedEventListener listener); boolean removeChainDownloadStartedEventListener(ChainDownloadStartedEventListener listener); boolean removeConnectedEventListener(PeerConnectedEventListener listener); boolean removeDisconnectedEventListener(PeerDisconnectedEventListener listener); boolean removeGetDataEventListener(GetDataEventListener listener); boolean removeOnTransactionBroadcastListener(OnTransactionBroadcastListener listener); boolean removePreMessageReceivedEventListener(PreMessageReceivedEventListener listener); @Override String toString(); @Override void connectionClosed(); @Override void connectionOpened(); ListenableFuture<Peer> getConnectionOpenFuture(); ListenableFuture<Peer> getVersionHandshakeFuture(); ListenableFuture<List<Transaction>> downloadDependencies(Transaction tx); @SuppressWarnings("unchecked") // The 'unchecked conversion' warning being suppressed here comes from the sendSingleGetData() formally returning // ListenableFuture instead of ListenableFuture<Block>. This is okay as sendSingleGetData() actually returns // ListenableFuture<Block> in this context. Note that sendSingleGetData() is also used for Transactions. ListenableFuture<Block> getBlock(Sha256Hash blockHash); @SuppressWarnings("unchecked") // The 'unchecked conversion' warning being suppressed here comes from the sendSingleGetData() formally returning // ListenableFuture instead of ListenableFuture<Transaction>. This is okay as sendSingleGetData() actually returns // ListenableFuture<Transaction> in this context. Note that sendSingleGetData() is also used for Blocks. ListenableFuture<Transaction> getPeerMempoolTransaction(Sha256Hash hash); ListenableFuture<AddressMessage> getAddr(); void setDownloadParameters(long secondsSinceEpoch, boolean useFilteredBlocks); void addWallet(Wallet wallet); void removeWallet(Wallet wallet); void startBlockChainDownload(); ListenableFuture<Long> ping(); long getLastPingTime(); long getPingTime(); int getPeerBlockHeightDifference(); boolean isDownloadData(); void setDownloadData(boolean downloadData); VersionMessage getPeerVersionMessage(); VersionMessage getVersionMessage(); long getBestHeight(); boolean setMinProtocolVersion(int minProtocolVersion); void setBloomFilter(BloomFilter filter); void setBloomFilter(BloomFilter filter, boolean andQueryMemPool); BloomFilter getBloomFilter(); ListenableFuture<UTXOsMessage> getUTXOs(List<TransactionOutPoint> outPoints); ListenableFuture<UTXOsMessage> getUTXOs(List<TransactionOutPoint> outPoints, boolean includeMempool); boolean isDownloadTxDependencies(); void setDownloadTxDependencies(boolean enable); void setDownloadTxDependencies(int depth); void notifyLock(Transaction tx); boolean isMasternode(); int getMasternodeListCount(); void setMasternodeListCount(int count); void askFor(InventoryItem item); void pushInventory(InventoryItem item); static final int MAPASKFOR_MAX_SZ; static final int SETASKFOR_MAX_SZ; public HashSet<Sha256Hash> setAskFor; }
@Test public void testAddConnectedEventListener() throws Exception { connect(); PeerConnectedEventListener listener = new AbstractPeerConnectionEventListener() { }; assertFalse(peer.removeConnectedEventListener(listener)); peer.addConnectedEventListener(listener); assertTrue(peer.removeConnectedEventListener(listener)); assertFalse(peer.removeConnectedEventListener(listener)); }