@@ -0,0 +1,2124 @@
+package org.bitcoinj.examples;%0A%0Aimport org.bitcoinj.core.*;%0Aimport org.bitcoinj.net.discovery.DnsDiscovery;%0Aimport org.bitcoinj.params.MainNetParams;%0Aimport org.bitcoinj.store.BlockStore;%0Aimport org.bitcoinj.store.BlockStoreException;%0Aimport org.bitcoinj.store.MemoryBlockStore;%0A%0Aimport java.io.IOException;%0Aimport java.util.concurrent.ExecutionException;%0Aimport java.util.concurrent.Future;%0A%0Apublic class DownloadBlocks %7B%0A    public static void main(String%5B%5D args) throws BlockStoreException, ExecutionException, InterruptedException %7B%0A        System.out.println(%22Connecting to node%22);%0A        final NetworkParameters params = MainNetParams.get();%0A        BlockStore blockStore = new MemoryBlockStore(params);%0A        BlockChain chain = new BlockChain(params, blockStore);%0A        PeerGroup peerGroup = new PeerGroup(params, chain);%0A        peerGroup.addPeerDiscovery(new DnsDiscovery(params));%0A        peerGroup.setUseLocalhostPeerWhenPossible(false);%0A%0A        peerGroup.start();%0A        peerGroup.waitForPeers(10).get();%0A        Peer peer = peerGroup.getDownloadPeer();%0A%0A        for (String hash : new String%5B%5D%7B%0A                %220000000000000011fbdfb7ebea7b3b68c11c82f68fe792e4a376f0f3e1ebfee5%22,%0A                %22000000000000001b7c5666cbda73912a5bcff8fc179fdd421fc9bfe7b7e7be73%22,%0A                %22000000000000000cdf5cc24c3beb0669b31e942d1301e07b53d6f0c7db10860d%22, // %3C%3C%3C%3C%3C doesn't work with dashj-0.13 branch%0A        %7D) %7B%0A%0A            Sha256Hash blockHash = Sha256Hash.wrap(hash);%0A            Future%3CBlock%3E future = peer.getBlock(blockHash);%0A            System.out.println(%22Waiting for node to send us the requested block: %22 + blockHash);%0A            Block block = future.get();%0A            System.out.println(block);%0A            try %7B%0A                UnsafeByteArrayOutputStream bos = new UnsafeByteArrayOutputStream(block.getMessageSize());%0A                block.bitcoinSerialize(bos);%0A                System.out.println(Utils.HEX.encode(bos.toByteArray()));%0A            %7D catch(IOException x) %7B%0A                throw new RuntimeException(x.getMessage());%0A            %7D%0A        %7D%0A        peerGroup.stopAsync();%0A    %7D%0A%7D%0A

Add Download blocks to test block processing