3
0
mirror of https://github.com/Qortal/altcoinj.git synced 2025-02-07 06:44:16 +00:00

Fix serialization UIDs, other cleanup

This commit is contained in:
Miron Cuperman (devrandom) 2011-10-19 18:42:38 +00:00
parent 228f30f663
commit a4a711e2df
5 changed files with 17 additions and 5 deletions

View File

@ -7,6 +7,7 @@ package com.google.bitcoin.core;
* @author git
*/
public abstract class ChildMessage extends Message {
private static final long serialVersionUID = -7657113383624517931L;
private Message parent;

View File

@ -10,6 +10,7 @@ import java.io.OutputStream;
* @author git
*/
public abstract class EmptyMessage extends Message {
private static final long serialVersionUID = 8240801253854151802L;
public EmptyMessage() {
length = 0;

View File

@ -17,6 +17,7 @@
package com.google.bitcoin.core;
public class GetAddrMessage extends EmptyMessage {
private static final long serialVersionUID = 6204437624599661503L;
public GetAddrMessage(NetworkParameters params) {
super(params);

View File

@ -26,6 +26,8 @@ import java.util.List;
* Abstract superclass of classes with list based payload, i.e. InventoryMessage and GetDataMessage.
*/
public abstract class ListMessage extends Message {
private static final long serialVersionUID = -4275896329391143643L;
private long arrayLen;
// For some reason the compiler complains if this is inside InventoryItem
private List<InventoryItem> items;

View File

@ -84,7 +84,6 @@ public abstract class Message implements Serializable {
this(params, msg, offset, protocolVersion, false, false, UNKNOWN_LENGTH);
}
@SuppressWarnings("unused")
Message(NetworkParameters params, byte[] msg, int offset, int protocolVersion, final boolean parseLazy, final boolean parseRetain, int length) throws ProtocolException {
this.parseLazy = parseLazy;
this.parseRetain = parseRetain;
@ -103,7 +102,17 @@ public abstract class Message implements Serializable {
assert this.length != UNKNOWN_LENGTH: "Length field has not been set in constructor for " + getClass().getSimpleName() + " after " + (parseLazy ? "lite" : "full") + " parse. Refer to Message.parseLite() for detail of required Length field contract.";
if (SELF_CHECK && !this.getClass().getSimpleName().equals("VersionMessage")) {
if (SELF_CHECK) {
selfCheck(msg, offset);
}
if (parseRetain || !parsed)
return;
this.bytes = null;
}
private void selfCheck(byte[] msg, int offset) {
if (!(this instanceof VersionMessage)) {
checkParse();
byte[] msgbytes = new byte[cursor - offset];
System.arraycopy(msg, offset, msgbytes, 0, cursor - offset);
@ -113,9 +122,6 @@ public abstract class Message implements Serializable {
Utils.bytesToHexString(reserialized) + " vs \n" +
Utils.bytesToHexString(msgbytes));
}
if (parseRetain || !parsed)
return;
this.bytes = null;
}
Message(NetworkParameters params, byte[] msg, int offset) throws ProtocolException {
@ -442,6 +448,7 @@ public abstract class Message implements Serializable {
}
public class LazyParseException extends RuntimeException {
private static final long serialVersionUID = 6971943053112975594L;
public LazyParseException(String message, Throwable cause) {
super(message, cause);