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:
parent
910544ae57
commit
fae82e0f2b
@ -87,11 +87,8 @@ public class AddressMessage extends Message {
|
|||||||
length += addresses.size() * (protocolVersion > 31402 ? PeerAddress.MESSAGE_SIZE : PeerAddress.MESSAGE_SIZE - 4);
|
length += addresses.size() * (protocolVersion > 31402 ? PeerAddress.MESSAGE_SIZE : PeerAddress.MESSAGE_SIZE - 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see Message#bitcoinSerializeToStream(java.io.OutputStream)
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
void bitcoinSerializeToStream(OutputStream stream) throws IOException {
|
protected void bitcoinSerializeToStream(OutputStream stream) throws IOException {
|
||||||
if (addresses == null)
|
if (addresses == null)
|
||||||
return;
|
return;
|
||||||
stream.write(new VarInt(addresses.size()).encode());
|
stream.write(new VarInt(addresses.size()).encode());
|
||||||
|
@ -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().
|
* Serializes this message to the provided stream. If you just want the raw bytes use bitcoinSerialize().
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
void bitcoinSerializeToStream(OutputStream stream) throws IOException {
|
protected void bitcoinSerializeToStream(OutputStream stream) throws IOException {
|
||||||
stream.write(new VarInt(data.length).encode());
|
stream.write(new VarInt(data.length).encode());
|
||||||
stream.write(data);
|
stream.write(data);
|
||||||
Utils.uint32ToByteStreamLE(hashFuncs, stream);
|
Utils.uint32ToByteStreamLE(hashFuncs, stream);
|
||||||
|
@ -81,7 +81,7 @@ public class GetUTXOsMessage extends Message {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@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 byte[]{includeMempool ? (byte) 1 : 0}); // include mempool.
|
||||||
stream.write(new VarInt(outPoints.size()).encode());
|
stream.write(new VarInt(outPoints.size()).encode());
|
||||||
for (TransactionOutPoint outPoint : outPoints) {
|
for (TransactionOutPoint outPoint : outPoints) {
|
||||||
|
@ -34,5 +34,5 @@ public class MemoryPoolMessage extends Message {
|
|||||||
protected void parse() throws ProtocolException {}
|
protected void parse() throws ProtocolException {}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
void bitcoinSerializeToStream(OutputStream stream) throws IOException {}
|
protected void bitcoinSerializeToStream(OutputStream stream) throws IOException {}
|
||||||
}
|
}
|
||||||
|
@ -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),
|
this(params, payload, offset, params.getProtocolVersionNum(NetworkParameters.ProtocolVersion.CURRENT),
|
||||||
params.getDefaultSerializer(), UNKNOWN_LENGTH);
|
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),
|
this(params, payload, offset, params.getProtocolVersionNum(NetworkParameters.ProtocolVersion.CURRENT),
|
||||||
serializer, length);
|
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().
|
* 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());
|
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;
|
return length;
|
||||||
}
|
}
|
||||||
|
|
||||||
long readUint32() throws ProtocolException {
|
protected long readUint32() throws ProtocolException {
|
||||||
try {
|
try {
|
||||||
long u = Utils.readUint32(payload, cursor);
|
long u = Utils.readUint32(payload, cursor);
|
||||||
cursor += 4;
|
cursor += 4;
|
||||||
@ -297,7 +297,7 @@ public abstract class Message {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
long readInt64() throws ProtocolException {
|
protected long readInt64() throws ProtocolException {
|
||||||
try {
|
try {
|
||||||
long u = Utils.readInt64(payload, cursor);
|
long u = Utils.readInt64(payload, cursor);
|
||||||
cursor += 8;
|
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.
|
// Java does not have an unsigned 64 bit type. So scrape it off the wire then flip.
|
||||||
return new BigInteger(Utils.reverseBytes(readBytes(8)));
|
return new BigInteger(Utils.reverseBytes(readBytes(8)));
|
||||||
}
|
}
|
||||||
|
|
||||||
long readVarInt() throws ProtocolException {
|
protected long readVarInt() throws ProtocolException {
|
||||||
return readVarInt(0);
|
return readVarInt(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
long readVarInt(int offset) throws ProtocolException {
|
protected long readVarInt(int offset) throws ProtocolException {
|
||||||
try {
|
try {
|
||||||
VarInt varint = new VarInt(payload, cursor + offset);
|
VarInt varint = new VarInt(payload, cursor + offset);
|
||||||
cursor += offset + varint.getOriginalSizeInBytes();
|
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) {
|
if (length > MAX_SIZE) {
|
||||||
throw new ProtocolException("Claimed value length too large: " + length);
|
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();
|
long len = readVarInt();
|
||||||
return readBytes((int)len);
|
return readBytes((int)len);
|
||||||
}
|
}
|
||||||
|
|
||||||
String readStr() throws ProtocolException {
|
protected String readStr() throws ProtocolException {
|
||||||
long length = readVarInt();
|
long length = readVarInt();
|
||||||
return length == 0 ? "" : Utils.toString(readBytes((int) length), "UTF-8"); // optimization for empty strings
|
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.
|
// 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.
|
// Not the most efficient way to do this but the clearest.
|
||||||
return Sha256Hash.wrapReversed(readBytes(32));
|
return Sha256Hash.wrapReversed(readBytes(32));
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean hasMoreBytes() {
|
protected boolean hasMoreBytes() {
|
||||||
return cursor < payload.length;
|
return cursor < payload.length;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -77,7 +77,7 @@ public class UTXOsMessage extends Message {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
void bitcoinSerializeToStream(OutputStream stream) throws IOException {
|
protected void bitcoinSerializeToStream(OutputStream stream) throws IOException {
|
||||||
Utils.uint32ToByteStreamLE(height, stream);
|
Utils.uint32ToByteStreamLE(height, stream);
|
||||||
stream.write(chainHead.getBytes());
|
stream.write(chainHead.getBytes());
|
||||||
stream.write(new VarInt(hits.length).encode());
|
stream.write(new VarInt(hits.length).encode());
|
||||||
|
Loading…
x
Reference in New Issue
Block a user