3
0
mirror of https://github.com/Qortal/altcoinj.git synced 2025-02-14 11:15:51 +00:00

Add a toString for reject messages.

This commit is contained in:
Mike Hearn 2014-04-15 13:34:18 +02:00
parent d2def04a00
commit f19741d2ab

View File

@ -18,9 +18,6 @@ package com.google.bitcoin.core;
import java.io.IOException;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
/**
* A message sent by nodes when a message we sent was rejected (ie a transaction had too little fee/was invalid/etc)
@ -141,6 +138,17 @@ public class RejectMessage extends Message {
return reason;
}
@Override
public String toString() {
Sha256Hash hash = getRejectedObjectHash();
if (hash != null)
return String.format("Reject: %s %s for reason '%s' (%d)", getRejectedMessage(), getRejectedObjectHash(),
getReasonString(), getReasonCode().code);
else
return String.format("Reject: %s for reason '%s' (%d)", getRejectedMessage(),
getReasonString(), getReasonCode().code);
}
@Override
public boolean equals(Object o) {
return o instanceof RejectMessage &&
@ -149,4 +157,13 @@ public class RejectMessage extends Message {
((RejectMessage) o).reason.equals(reason) &&
((RejectMessage) o).messageHash.equals(messageHash);
}
@Override
public int hashCode() {
int result = message.hashCode();
result = 31 * result + reason.hashCode();
result = 31 * result + code.hashCode();
result = 31 * result + messageHash.hashCode();
return result;
}
}