Changed the VoterRegistryMessage to wrap UnsignedBulletinBoardMessage

there is no need to wrap unused basic message when using UnsignedBulletinBoardMessage
Voter-Registry
Vladimir Eliezer Tokarev 2016-01-22 08:03:52 -08:00
parent 1815863746
commit dfc5bf4b24
1 changed files with 12 additions and 11 deletions

View File

@ -1,5 +1,6 @@
package meerkat;
import meerkat.protobuf.BulletinBoardAPI;
import util.AccurateTimestamp;
import util.RegistryTags;
@ -12,10 +13,10 @@ import java.text.ParseException;
*/
public class VoterRegistryMessage {
public ProtobufsMessages.BasicMessage base;
public BulletinBoardAPI.UnsignedBulletinBoardMessage base;
public VoterRegistryMessage(ProtobufsMessages.BasicMessage message){
base = ProtobufsMessages.BasicMessage.newBuilder().addAllTag(message.getTagList()).build();
public VoterRegistryMessage(BulletinBoardAPI.UnsignedBulletinBoardMessage message){
base = BulletinBoardAPI.UnsignedBulletinBoardMessage.newBuilder().addAllTag(message.getTagList()).build();
}
/**
@ -24,9 +25,9 @@ public class VoterRegistryMessage {
* @return string
*/
public String GetWantedTagFromBasicMessage(RegistryTags tagName){
for (ProtobufsMessages.Tag tag : base.getTagList()) {
if ( tag.getContent().contains(tagName.toString())) {
return tag.getContent();
for (String tag : base.getTagList()) {
if ( tag.contains(tagName.toString())) {
return tag;
}
}
return null;
@ -38,9 +39,9 @@ public class VoterRegistryMessage {
* @throws ParseException
*/
public Timestamp GetBasicMessageActionTimestamp() throws ParseException {
for (ProtobufsMessages.Tag tag : base.getTagList()) {
if ( tag.getContent().contains(RegistryTags.ACTION_TIMESTAMP_TAG.toString())) {
String[] tagParts = tag.getContent().split(" ");
for (String tag : base.getTagList()) {
if ( tag.contains(RegistryTags.ACTION_TIMESTAMP_TAG.toString())) {
String[] tagParts = tag.split(" ");
String timestamp = tagParts[tagParts.length - 1];
return AccurateTimestamp.GetTimestampFromString(timestamp);
}
@ -54,8 +55,8 @@ public class VoterRegistryMessage {
* @return true when ADD_TO_GROUP_TAG exist else false
*/
public boolean IsGroupAdding() {
for (ProtobufsMessages.Tag tag : base.getTagList()) {
if ( tag.getContent().contains(RegistryTags.ADD_TO_GROUP_TAG.toString())) {
for (String tag : base.getTagList()) {
if ( tag.contains(RegistryTags.ADD_TO_GROUP_TAG.toString())) {
return true;
}
}