@Test public void getLargeBlock() throws Exception { connect(); Block b1 = createFakeBlock(blockStore, Block.BLOCK_HEIGHT_GENESIS).block; blockChain.add(b1); Block b2 = makeSolvedTestBlock(b1); Transaction t = new Transaction(UNITTEST); t.addInput(b1.getTransactions().get(0).getOutput(0)); t.addOutput(new TransactionOutput(UNITTEST, t, Coin.ZERO, new byte[Block.MAX_BLOCK_SIZE - 1000])); b2.addTransaction(t); Future<Block> resultFuture = peer.getBlock(b2.getHash()); assertFalse(resultFuture.isDone()); GetDataMessage message = (GetDataMessage) outbound(writeTarget); assertEquals(message.getItems().get(0).hash, b2.getHash()); assertFalse(resultFuture.isDone()); inbound(writeTarget, b2); Block b = resultFuture.get(); assertEquals(b, b2); }
@SuppressWarnings("unchecked") public ListenableFuture<Block> getBlock(Sha256Hash blockHash) { log.info("Request to fetch block {}", blockHash); GetDataMessage getdata = new GetDataMessage(params); getdata.addBlock(blockHash, true); return sendSingleGetData(getdata); }
Peer extends PeerSocketHandler { @SuppressWarnings("unchecked") public ListenableFuture<Block> getBlock(Sha256Hash blockHash) { log.info("Request to fetch block {}", blockHash); GetDataMessage getdata = new GetDataMessage(params); getdata.addBlock(blockHash, true); return sendSingleGetData(getdata); } }
Peer extends PeerSocketHandler { @SuppressWarnings("unchecked") public ListenableFuture<Block> getBlock(Sha256Hash blockHash) { log.info("Request to fetch block {}", blockHash); GetDataMessage getdata = new GetDataMessage(params); getdata.addBlock(blockHash, true); return sendSingleGetData(getdata); } @Deprecated  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, long requiredServices, int downloadTxDependencyDepth);  Peer(NetworkParameters params, AbstractBlockChain blockChain, PeerAddress peerAddress, String thisSoftwareName, String thisSoftwareVersion); }
Peer extends PeerSocketHandler { @SuppressWarnings("unchecked") public ListenableFuture<Block> getBlock(Sha256Hash blockHash) { log.info("Request to fetch block {}", blockHash); GetDataMessage getdata = new GetDataMessage(params); getdata.addBlock(blockHash, true); return sendSingleGetData(getdata); } @Deprecated  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, long requiredServices, int downloadTxDependencyDepth);  Peer(NetworkParameters params, AbstractBlockChain blockChain, PeerAddress peerAddress, String thisSoftwareName, String thisSoftwareVersion); 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(); @Deprecated String toStringServices(long services); @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); }
Peer extends PeerSocketHandler { @SuppressWarnings("unchecked") public ListenableFuture<Block> getBlock(Sha256Hash blockHash) { log.info("Request to fetch block {}", blockHash); GetDataMessage getdata = new GetDataMessage(params); getdata.addBlock(blockHash, true); return sendSingleGetData(getdata); } @Deprecated  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, long requiredServices, int downloadTxDependencyDepth);  Peer(NetworkParameters params, AbstractBlockChain blockChain, PeerAddress peerAddress, String thisSoftwareName, String thisSoftwareVersion); 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(); @Deprecated String toStringServices(long services); @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);  }