/** * Process the 'getblocks' message and return an 'inv' message * * @param msg Message * @param inBuffer Input buffer * @param msgListener Message listener * @throws EOFException End-of-data processing stream * @throws VerificationException Message verification failed */ public static void processGetBlocksMessage( Message msg, SerializedBuffer inBuffer, MessageListener msgListener) throws EOFException, VerificationException { // // Process the message // int version = inBuffer.getInt(); if (version < NetParams.MIN_PROTOCOL_VERSION) throw new VerificationException( String.format("Protocol version %d is not supported", version)); int count = inBuffer.getVarInt(); if (count < 0 || count > 500) throw new VerificationException("More than 500 locator entries in 'getblocks' message"); List<Sha256Hash> blockList = new ArrayList<>(count); for (int i = 0; i < count; i++) blockList.add(new Sha256Hash(Helper.reverseBytes(inBuffer.getBytes(32)))); Sha256Hash stopBlock = new Sha256Hash(Helper.reverseBytes(inBuffer.getBytes(32))); // // Notify the message listener // msgListener.processGetBlocks(msg, version, blockList, stopBlock); }