use of pubsub.pb.Rpc.Message in project teku by ConsenSys.
the class MockMessageApi method getOriginalMessage.
@NotNull
@Override
public PubsubMessage getOriginalMessage() {
Message protoMessage = Message.newBuilder().addAllTopicIDs(getTopics().stream().map(Topic::getTopic).collect(Collectors.toList())).setData(ByteString.copyFrom(getData().nioBuffer())).build();
PreparedGossipMessage preparedMessage = new PreparedGossipMessage() {
@Override
public Bytes getMessageId() {
return Bytes.wrap(Hash.sha256(protoMessage.getData().toByteArray()));
}
@Override
public DecodedMessageResult getDecodedMessage() {
final Bytes decoded = Bytes.of(protoMessage.getData().toByteArray());
return DecodedMessageResult.successful(decoded);
}
@Override
public Bytes getOriginalMessage() {
return Bytes.wrapByteBuf(data);
}
};
return new PreparedPubsubMessage(protoMessage, preparedMessage);
}
Aggregations