@@ -71,39 +71,39 @@ public class HbftClient extends Client {
71
71
*/
72
72
@ Override
73
73
public void sendRequest () {
74
- String requestId = String .format ("%s/%d" , super . id , super . requestSequenceNumber .incrementAndGet ());
74
+ String requestId = String .format ("%s/%d" , getId (), getRequestSequenceNumber () .incrementAndGet ());
75
75
long timestamp = this .getCurrentTime ().toEpochMilli ();
76
- RequestMessage request = new RequestMessage (requestId , timestamp , super . id );
77
- this .sentRequests .put (super . requestSequenceNumber .get (), request );
76
+ RequestMessage request = new RequestMessage (requestId , timestamp , getId () );
77
+ this .sentRequests .put (getRequestSequenceNumber () .get (), request );
78
78
this .sentRequestsByTimestamp .put (timestamp , requestId );
79
79
this .broadcastRequest (timestamp , requestId );
80
80
81
81
// Set timeout
82
82
Long timeoutId = this .setTimeout ("REQUEST" , this ::retransmitOrPanic , this .timeout );
83
- timeouts .put (super . requestSequenceNumber .get (), timeoutId );
83
+ timeouts .put (getRequestSequenceNumber () .get (), timeoutId );
84
84
}
85
85
86
86
public void retransmitOrPanic () {
87
- long tolerance = (long ) Math .floor ((super . scenario .getTransport ().getNodeIds ().size () - 1 ) / 3 );
87
+ long tolerance = (long ) Math .floor ((getScenario () .getTransport ().getNodeIds ().size () - 1 ) / 3 );
88
88
if (this .shouldRetransmit (tolerance )) {
89
- String requestId = String .format ("%s/%d" , super . id , super . requestSequenceNumber .get ());
89
+ String requestId = String .format ("%s/%d" , getId (), getRequestSequenceNumber () .get ());
90
90
// Based on hBFT 4.1 it uses the identical request
91
91
// TODO: It probably should not be the same timestamp
92
- long timestamp = this .sentRequests .get (super . requestSequenceNumber .get ()).getTimestamp ();
92
+ long timestamp = this .sentRequests .get (getRequestSequenceNumber () .get ()).getTimestamp ();
93
93
this .broadcastRequest (timestamp , requestId );
94
94
} else if (this .shouldPanic (tolerance )) {
95
- RequestMessage message = this .sentRequests .get (super . requestSequenceNumber .get ());
96
- PanicMessage panic = new PanicMessage (this .digest (message ), this .getCurrentTime ().toEpochMilli (), super . id );
97
- super . scenario . getTransport ().multicast (this , super . scenario .getTransport ().getNodeIds (), panic );
95
+ RequestMessage message = this .sentRequests .get (getRequestSequenceNumber () .get ());
96
+ PanicMessage panic = new PanicMessage (this .digest (message ), this .getCurrentTime ().toEpochMilli (), getId () );
97
+ getScenario (). getTransport ().multicast (this , getScenario () .getTransport ().getNodeIds (), panic );
98
98
}
99
- this .clearTimeout (timeouts .get (super . requestSequenceNumber .get ()));
99
+ this .clearTimeout (timeouts .get (getRequestSequenceNumber () .get ()));
100
100
Long timeoutId = this .setTimeout ("REQUEST" , this ::retransmitOrPanic , this .timeout );
101
- timeouts .put (super . requestSequenceNumber .get (), timeoutId );
101
+ timeouts .put (getRequestSequenceNumber () .get (), timeoutId );
102
102
}
103
103
104
104
private void broadcastRequest (long timestamp , String requestId ) {
105
105
MessagePayload payload = new ClientRequestMessage (timestamp , requestId );
106
- SortedSet <String > replicaIds = super . scenario .getTransport ().getNodeIds ();
106
+ SortedSet <String > replicaIds = getScenario () .getTransport ().getNodeIds ();
107
107
getScenario ().getTransport ().multicast (this , replicaIds , payload );
108
108
}
109
109
@@ -131,9 +131,9 @@ public void handleMessage(String senderId, MessagePayload payload) {
131
131
*/
132
132
if (this .completedReplies (clientReplyMessage .getTolerance ())
133
133
&& !this .completedRequests .contains (key )
134
- && super . requestSequenceNumber . get () <= this . maxRequests ) {
134
+ && getRequestSequenceNumber (). get () <= getMaxRequests () ) {
135
135
this .completedRequests .add (key );
136
- this .clearTimeout (this .timeouts .get (super . requestSequenceNumber .get ()));
136
+ this .clearTimeout (this .timeouts .get (getRequestSequenceNumber () .get ()));
137
137
this .sendRequest ();
138
138
}
139
139
}
@@ -148,15 +148,15 @@ public void handleMessage(String senderId, MessagePayload payload) {
148
148
*/
149
149
public long setTimeout (String name , Runnable r , long timeout ) {
150
150
Duration duration = Duration .ofSeconds (timeout );
151
- return super . scenario .getTransport ().setTimeout (this , r , duration , name );
151
+ return getScenario () .getTransport ().setTimeout (this , r , duration , name );
152
152
}
153
153
154
154
/**
155
155
* Checks whether client should retransmit the request
156
156
* if #replies < f + 1
157
157
*/
158
158
public boolean shouldRetransmit (long tolerance ) {
159
- String currRequest = String .format ("%s/%d" , super . id , super . requestSequenceNumber .get ());
159
+ String currRequest = String .format ("%s/%d" , getId (), getRequestSequenceNumber () .get ());
160
160
if (!hbftreplies .containsKey (currRequest )) {
161
161
return true ;
162
162
}
@@ -171,7 +171,7 @@ public boolean shouldRetransmit(long tolerance) {
171
171
* if f + 1 <= #replies < 2f + 1
172
172
*/
173
173
public boolean shouldPanic (long tolerance ) {
174
- String currRequest = String .format ("%s/%d" , super . id , super . requestSequenceNumber .get ());
174
+ String currRequest = String .format ("%s/%d" , getId (), getRequestSequenceNumber () .get ());
175
175
for (ClientReplyKey key : hbftreplies .get (currRequest ).keySet ()) {
176
176
return this .hbftreplies .get (currRequest ).get (key ).size () >= tolerance + 1
177
177
&& this .hbftreplies .get (currRequest ).get (key ).size () < tolerance * 2 + 1 ;
@@ -183,7 +183,7 @@ public boolean shouldPanic(long tolerance) {
183
183
* Checks whether it has received 2f + 1 replies
184
184
*/
185
185
public boolean completedReplies (long tolerance ) {
186
- String currRequest = String .format ("%s/%d" , super . id , super . requestSequenceNumber .get ());
186
+ String currRequest = String .format ("%s/%d" , getId (), getRequestSequenceNumber () .get ());
187
187
if (!hbftreplies .containsKey (currRequest )) {
188
188
return false ;
189
189
}
@@ -199,7 +199,7 @@ public boolean completedReplies(long tolerance) {
199
199
* Clear all timeouts for this client.
200
200
*/
201
201
// public void clearAllTimeouts() {
202
- // super.scenario. getTransport().clearClientTimeouts(super.id );
202
+ // getScenario. getTransport().clearClientTimeouts(getId() );
203
203
// }
204
204
205
205
/**
0 commit comments