public static Message decodeRelayedMessage(Buffer buf, InetSocketAddress recipient, InetSocketAddress sender,
SignatureFactory signatureFactory) throws InvalidKeyException, NoSuchAlgorithmException,
InvalidKeySpecException, SignatureException, IOException {
Message decodedMessage = decodeMessage(buf, recipient, sender, signatureFactory);
boolean isRelay = decodedMessage.sender().isRelayed();
if (isRelay && !decodedMessage.peerSocketAddresses().isEmpty()) {
PeerAddress tmpSender = decodedMessage.sender().changePeerSocketAddresses(decodedMessage.peerSocketAddresses());
decodedMessage.sender(tmpSender);
}
return decodedMessage;
}