From bfcf67ee5aa599adb2049d95bb0f11c1f8529f64 Mon Sep 17 00:00:00 2001 From: Mike Hearn Date: Sun, 20 Jan 2013 22:17:22 +0100 Subject: [PATCH] Allow NotFoundMessage to be constructed with a list of InventoryItems. --- .../main/java/com/google/bitcoin/core/ListMessage.java | 4 ++-- .../java/com/google/bitcoin/core/NotFoundMessage.java | 8 ++++++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/core/src/main/java/com/google/bitcoin/core/ListMessage.java b/core/src/main/java/com/google/bitcoin/core/ListMessage.java index 5189e6b9..9f14b452 100644 --- a/core/src/main/java/com/google/bitcoin/core/ListMessage.java +++ b/core/src/main/java/com/google/bitcoin/core/ListMessage.java @@ -30,9 +30,9 @@ public abstract class ListMessage extends Message { private long arrayLen; // For some reason the compiler complains if this is inside InventoryItem - private List items; + protected List items; - private static final long MAX_INVENTORY_ITEMS = 50000; + public static final long MAX_INVENTORY_ITEMS = 50000; public ListMessage(NetworkParameters params, byte[] bytes) throws ProtocolException { diff --git a/core/src/main/java/com/google/bitcoin/core/NotFoundMessage.java b/core/src/main/java/com/google/bitcoin/core/NotFoundMessage.java index 9ac5b1f2..6eaa3d1f 100644 --- a/core/src/main/java/com/google/bitcoin/core/NotFoundMessage.java +++ b/core/src/main/java/com/google/bitcoin/core/NotFoundMessage.java @@ -16,6 +16,9 @@ package com.google.bitcoin.core; +import java.util.ArrayList; +import java.util.List; + /** * Sent by a peer when a getdata request doesn't find the requested data in the mempool. It has the same format * as an inventory message and lists the hashes of the missing items. @@ -28,4 +31,9 @@ public class NotFoundMessage extends InventoryMessage { public NotFoundMessage(NetworkParameters params, byte[] payloadBytes) throws ProtocolException { super(params, payloadBytes); } + + public NotFoundMessage(NetworkParameters unitTestParams, List items) { + super(unitTestParams); + this.items = new ArrayList(items); + } }