3
0
mirror of https://github.com/Qortal/altcoinj.git synced 2025-02-12 18:25:51 +00:00

Print out alert messages to the log.

This commit is contained in:
Mike Hearn 2012-02-19 12:22:43 +01:00
parent 0e198e68e8
commit 68424281c5
2 changed files with 10 additions and 1 deletions

View File

@ -335,7 +335,6 @@ public class BitcoinSerializer {
} else if (command.equals("headers")) {
return new HeadersMessage(params, payloadBytes);
} else if (command.equals("alert")) {
log.info("alert payload " + Utils.bytesToHexString(payloadBytes));
return new AlertMessage(params, payloadBytes);
} else {
log.warn("No support for deserializing message with name {}", command);

View File

@ -209,6 +209,8 @@ public class Peer {
// properly explore the network.
} else if (m instanceof HeadersMessage) {
processHeaders((HeadersMessage) m);
} else if (m instanceof AlertMessage) {
processAlert((AlertMessage)m);
} else {
// TODO: Handle the other messages we can receive.
log.warn("Received unhandled message: {}", m);
@ -234,6 +236,14 @@ public class Peer {
disconnect();
}
private void processAlert(AlertMessage m) {
if (m.isSignatureValid()) {
log.info("Received alert from peer {}: {}", toString(), m.getStatusBar());
} else {
log.warn("Received alert with invalid signature from peer {}: {}", toString(), m.getStatusBar());
}
}
private void processHeaders(HeadersMessage m) throws IOException, ProtocolException {
// Runs in network loop thread for this peer.
//