Skip to content

Commit 142c518

Browse files
committed
MessagePayload: derive signed from signedBy
1 parent dd85b79 commit 142c518

File tree

1 file changed

+30
-30
lines changed

1 file changed

+30
-30
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,40 @@
11
package byzzbench.simulator.transport;
22

3-
import java.io.Serializable;
4-
53
import lombok.Getter;
64

5+
import java.io.Serializable;
6+
77
/**
88
* Interface for the payload of a {@link MessageEvent}.
99
*/
1010
@Getter
1111
public abstract class MessagePayload implements Serializable {
12-
// Could be removed as we can just check
13-
// signedBy != null
14-
private boolean signed;
15-
private String signedBy;
16-
17-
/**
18-
* A string representation of the message type.
19-
*/
20-
public abstract String getType();
21-
22-
23-
/*
24-
* Dummy function to validate the signature of the
25-
* message instance. Returns true if the message was
26-
* signed by @param id.
27-
*/
28-
public boolean isSignedBy(String id) {
29-
return this.signed && this.signedBy.equals(id);
30-
}
31-
32-
/*
33-
* Dummy function to sign the message with the public
34-
* key of the @param sender.
35-
*/
36-
public void sign(String sender) {
37-
this.signed = true;
38-
this.signedBy = sender;
39-
}
12+
private String signedBy;
13+
14+
/**
15+
* A string representation of the message type.
16+
*/
17+
public abstract String getType();
18+
19+
20+
/*
21+
* Dummy function to validate the signature of the
22+
* message instance. Returns true if the message was
23+
* signed by @param id.
24+
*/
25+
public boolean isSignedBy(String id) {
26+
return this.isSigned() && this.signedBy.equals(id);
27+
}
28+
29+
/*
30+
* Dummy function to sign the message with the public
31+
* key of the @param sender.
32+
*/
33+
public void sign(String sender) {
34+
this.signedBy = sender;
35+
}
36+
37+
public boolean isSigned() {
38+
return this.signedBy != null;
39+
}
4040
}

0 commit comments

Comments
 (0)