3
0
mirror of https://github.com/Qortal/altcoinj.git synced 2025-02-13 10:45:51 +00:00

Message: Switch package-level-protected methods to protected.

This commit is contained in:
Andreas Schildbach 2016-03-21 15:14:44 +01:00
parent 910544ae57
commit fae82e0f2b
6 changed files with 18 additions and 21 deletions

View File

@ -87,11 +87,8 @@ public class AddressMessage extends Message {
length += addresses.size() * (protocolVersion > 31402 ? PeerAddress.MESSAGE_SIZE : PeerAddress.MESSAGE_SIZE - 4);
}
/* (non-Javadoc)
* @see Message#bitcoinSerializeToStream(java.io.OutputStream)
*/
@Override
void bitcoinSerializeToStream(OutputStream stream) throws IOException {
protected void bitcoinSerializeToStream(OutputStream stream) throws IOException {
if (addresses == null)
return;
stream.write(new VarInt(addresses.size()).encode());

View File

@ -149,7 +149,7 @@ public class BloomFilter extends Message {
* Serializes this message to the provided stream. If you just want the raw bytes use bitcoinSerialize().
*/
@Override
void bitcoinSerializeToStream(OutputStream stream) throws IOException {
protected void bitcoinSerializeToStream(OutputStream stream) throws IOException {
stream.write(new VarInt(data.length).encode());
stream.write(data);
Utils.uint32ToByteStreamLE(hashFuncs, stream);

View File

@ -81,7 +81,7 @@ public class GetUTXOsMessage extends Message {
}
@Override
void bitcoinSerializeToStream(OutputStream stream) throws IOException {
protected void bitcoinSerializeToStream(OutputStream stream) throws IOException {
stream.write(new byte[]{includeMempool ? (byte) 1 : 0}); // include mempool.
stream.write(new VarInt(outPoints.size()).encode());
for (TransactionOutPoint outPoint : outPoints) {

View File

@ -34,5 +34,5 @@ public class MemoryPoolMessage extends Message {
protected void parse() throws ProtocolException {}
@Override
void bitcoinSerializeToStream(OutputStream stream) throws IOException {}
protected void bitcoinSerializeToStream(OutputStream stream) throws IOException {}
}

View File

@ -119,12 +119,12 @@ public abstract class Message {
}
}
Message(NetworkParameters params, byte[] payload, int offset) throws ProtocolException {
protected Message(NetworkParameters params, byte[] payload, int offset) throws ProtocolException {
this(params, payload, offset, params.getProtocolVersionNum(NetworkParameters.ProtocolVersion.CURRENT),
params.getDefaultSerializer(), UNKNOWN_LENGTH);
}
Message(NetworkParameters params, byte[] payload, int offset, MessageSerializer serializer, int length) throws ProtocolException {
protected Message(NetworkParameters params, byte[] payload, int offset, MessageSerializer serializer, int length) throws ProtocolException {
this(params, payload, offset, params.getProtocolVersionNum(NetworkParameters.ProtocolVersion.CURRENT),
serializer, length);
}
@ -266,7 +266,7 @@ public abstract class Message {
/**
* Serializes this message to the provided stream. If you just want the raw bytes use bitcoinSerialize().
*/
void bitcoinSerializeToStream(OutputStream stream) throws IOException {
protected void bitcoinSerializeToStream(OutputStream stream) throws IOException {
log.error("Error: {} class has not implemented bitcoinSerializeToStream method. Generating message with no payload", getClass());
}
@ -287,7 +287,7 @@ public abstract class Message {
return length;
}
long readUint32() throws ProtocolException {
protected long readUint32() throws ProtocolException {
try {
long u = Utils.readUint32(payload, cursor);
cursor += 4;
@ -297,7 +297,7 @@ public abstract class Message {
}
}
long readInt64() throws ProtocolException {
protected long readInt64() throws ProtocolException {
try {
long u = Utils.readInt64(payload, cursor);
cursor += 8;
@ -307,16 +307,16 @@ public abstract class Message {
}
}
BigInteger readUint64() throws ProtocolException {
protected BigInteger readUint64() throws ProtocolException {
// Java does not have an unsigned 64 bit type. So scrape it off the wire then flip.
return new BigInteger(Utils.reverseBytes(readBytes(8)));
}
long readVarInt() throws ProtocolException {
protected long readVarInt() throws ProtocolException {
return readVarInt(0);
}
long readVarInt(int offset) throws ProtocolException {
protected long readVarInt(int offset) throws ProtocolException {
try {
VarInt varint = new VarInt(payload, cursor + offset);
cursor += offset + varint.getOriginalSizeInBytes();
@ -326,7 +326,7 @@ public abstract class Message {
}
}
byte[] readBytes(int length) throws ProtocolException {
protected byte[] readBytes(int length) throws ProtocolException {
if (length > MAX_SIZE) {
throw new ProtocolException("Claimed value length too large: " + length);
}
@ -340,23 +340,23 @@ public abstract class Message {
}
}
byte[] readByteArray() throws ProtocolException {
protected byte[] readByteArray() throws ProtocolException {
long len = readVarInt();
return readBytes((int)len);
}
String readStr() throws ProtocolException {
protected String readStr() throws ProtocolException {
long length = readVarInt();
return length == 0 ? "" : Utils.toString(readBytes((int) length), "UTF-8"); // optimization for empty strings
}
Sha256Hash readHash() throws ProtocolException {
protected Sha256Hash readHash() throws ProtocolException {
// We have to flip it around, as it's been read off the wire in little endian.
// Not the most efficient way to do this but the clearest.
return Sha256Hash.wrapReversed(readBytes(32));
}
boolean hasMoreBytes() {
protected boolean hasMoreBytes() {
return cursor < payload.length;
}

View File

@ -77,7 +77,7 @@ public class UTXOsMessage extends Message {
}
@Override
void bitcoinSerializeToStream(OutputStream stream) throws IOException {
protected void bitcoinSerializeToStream(OutputStream stream) throws IOException {
Utils.uint32ToByteStreamLE(height, stream);
stream.write(chainHead.getBytes());
stream.write(new VarInt(hits.length).encode());