use of org.ethereum.net.p2p.PingMessage in project rskj by rsksmart.
the class PingPongMessageTest method testPing.
/* PING_MESSAGE & PONG_MESSAGE */
@Test
public /* PingMessage */
void testPing() {
PingMessage pingMessage = new PingMessage();
System.out.println(pingMessage);
assertEquals(PongMessage.class, pingMessage.getAnswerMessage());
assertEquals(P2pMessageCodes.PING, pingMessage.getCommand());
}
use of org.ethereum.net.p2p.PingMessage in project rskj by rsksmart.
the class MessageQueue method receivedMessage.
public void receivedMessage(Message msg) throws InterruptedException {
MessageRoundtrip messageRoundtrip = requestQueue.peek();
if (messageRoundtrip != null) {
Message waitingMessage = messageRoundtrip.getMsg();
if (waitingMessage instanceof PingMessage) {
hasPing = false;
}
if (waitingMessage.getAnswerMessage() != null && msg.getClass() == waitingMessage.getAnswerMessage()) {
messageRoundtrip.answer();
if (waitingMessage instanceof EthMessage) {
channel.getPeerStats().pong(messageRoundtrip.lastTimestamp);
}
logger.trace("Message round trip covered: [{}] ", messageRoundtrip.getMsg().getClass());
}
}
}
Aggregations