mirror of
https://github.com/bitcoinj/bitcoinj.git
synced 2025-02-24 14:50:57 +01:00
Fix serialization UIDs, other cleanup
This commit is contained in:
parent
228f30f663
commit
a4a711e2df
5 changed files with 17 additions and 5 deletions
|
@ -7,6 +7,7 @@ package com.google.bitcoin.core;
|
||||||
* @author git
|
* @author git
|
||||||
*/
|
*/
|
||||||
public abstract class ChildMessage extends Message {
|
public abstract class ChildMessage extends Message {
|
||||||
|
private static final long serialVersionUID = -7657113383624517931L;
|
||||||
|
|
||||||
private Message parent;
|
private Message parent;
|
||||||
|
|
||||||
|
|
|
@ -10,6 +10,7 @@ import java.io.OutputStream;
|
||||||
* @author git
|
* @author git
|
||||||
*/
|
*/
|
||||||
public abstract class EmptyMessage extends Message {
|
public abstract class EmptyMessage extends Message {
|
||||||
|
private static final long serialVersionUID = 8240801253854151802L;
|
||||||
|
|
||||||
public EmptyMessage() {
|
public EmptyMessage() {
|
||||||
length = 0;
|
length = 0;
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
package com.google.bitcoin.core;
|
package com.google.bitcoin.core;
|
||||||
|
|
||||||
public class GetAddrMessage extends EmptyMessage {
|
public class GetAddrMessage extends EmptyMessage {
|
||||||
|
private static final long serialVersionUID = 6204437624599661503L;
|
||||||
|
|
||||||
public GetAddrMessage(NetworkParameters params) {
|
public GetAddrMessage(NetworkParameters params) {
|
||||||
super(params);
|
super(params);
|
||||||
|
|
|
@ -26,6 +26,8 @@ import java.util.List;
|
||||||
* Abstract superclass of classes with list based payload, i.e. InventoryMessage and GetDataMessage.
|
* Abstract superclass of classes with list based payload, i.e. InventoryMessage and GetDataMessage.
|
||||||
*/
|
*/
|
||||||
public abstract class ListMessage extends Message {
|
public abstract class ListMessage extends Message {
|
||||||
|
private static final long serialVersionUID = -4275896329391143643L;
|
||||||
|
|
||||||
private long arrayLen;
|
private long arrayLen;
|
||||||
// For some reason the compiler complains if this is inside InventoryItem
|
// For some reason the compiler complains if this is inside InventoryItem
|
||||||
private List<InventoryItem> items;
|
private List<InventoryItem> items;
|
||||||
|
|
|
@ -84,7 +84,6 @@ public abstract class Message implements Serializable {
|
||||||
this(params, msg, offset, protocolVersion, false, false, UNKNOWN_LENGTH);
|
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 {
|
Message(NetworkParameters params, byte[] msg, int offset, int protocolVersion, final boolean parseLazy, final boolean parseRetain, int length) throws ProtocolException {
|
||||||
this.parseLazy = parseLazy;
|
this.parseLazy = parseLazy;
|
||||||
this.parseRetain = parseRetain;
|
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.";
|
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();
|
checkParse();
|
||||||
byte[] msgbytes = new byte[cursor - offset];
|
byte[] msgbytes = new byte[cursor - offset];
|
||||||
System.arraycopy(msg, offset, msgbytes, 0, 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(reserialized) + " vs \n" +
|
||||||
Utils.bytesToHexString(msgbytes));
|
Utils.bytesToHexString(msgbytes));
|
||||||
}
|
}
|
||||||
if (parseRetain || !parsed)
|
|
||||||
return;
|
|
||||||
this.bytes = null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Message(NetworkParameters params, byte[] msg, int offset) throws ProtocolException {
|
Message(NetworkParameters params, byte[] msg, int offset) throws ProtocolException {
|
||||||
|
@ -442,6 +448,7 @@ public abstract class Message implements Serializable {
|
||||||
}
|
}
|
||||||
|
|
||||||
public class LazyParseException extends RuntimeException {
|
public class LazyParseException extends RuntimeException {
|
||||||
|
private static final long serialVersionUID = 6971943053112975594L;
|
||||||
|
|
||||||
public LazyParseException(String message, Throwable cause) {
|
public LazyParseException(String message, Throwable cause) {
|
||||||
super(message, cause);
|
super(message, cause);
|
||||||
|
|
Loading…
Add table
Reference in a new issue