File tree Expand file tree Collapse file tree 4 files changed +60
-0
lines changed Expand file tree Collapse file tree 4 files changed +60
-0
lines changed Original file line number Diff line number Diff line change @@ -206,6 +206,12 @@ func (c *Client) handleStartBatch() error {
206
206
"role" , "client" ,
207
207
"connection_id" , c .callbackContext .ConnectionId .String (),
208
208
)
209
+ // Check for shutdown
210
+ select {
211
+ case <- c .Protocol .DoneChan ():
212
+ return protocol .ProtocolShuttingDownError
213
+ default :
214
+ }
209
215
c .startBatchResultChan <- nil
210
216
return nil
211
217
}
@@ -218,6 +224,12 @@ func (c *Client) handleNoBlocks() error {
218
224
"role" , "client" ,
219
225
"connection_id" , c .callbackContext .ConnectionId .String (),
220
226
)
227
+ // Check for shutdown
228
+ select {
229
+ case <- c .Protocol .DoneChan ():
230
+ return protocol .ProtocolShuttingDownError
231
+ default :
232
+ }
221
233
err := fmt .Errorf ("block(s) not found" )
222
234
c .startBatchResultChan <- err
223
235
return nil
@@ -244,6 +256,12 @@ func (c *Client) handleBlock(msgGeneric protocol.Message) error {
244
256
if err != nil {
245
257
return err
246
258
}
259
+ // Check for shutdown
260
+ select {
261
+ case <- c .Protocol .DoneChan ():
262
+ return protocol .ProtocolShuttingDownError
263
+ default :
264
+ }
247
265
// We use the callback when requesting ranges and the internal channel for a single block
248
266
if c .blockUseCallback {
249
267
if err := c .config .BlockFunc (c .callbackContext , wrappedBlock .Type , blk ); err != nil {
Original file line number Diff line number Diff line change @@ -849,6 +849,12 @@ func (c *Client) handleAcquired() error {
849
849
"role" , "client" ,
850
850
"connection_id" , c .callbackContext .ConnectionId .String (),
851
851
)
852
+ // Check for shutdown
853
+ select {
854
+ case <- c .Protocol .DoneChan ():
855
+ return protocol .ProtocolShuttingDownError
856
+ default :
857
+ }
852
858
c .acquired = true
853
859
c .acquireResultChan <- nil
854
860
c .currentEra = - 1
@@ -863,6 +869,12 @@ func (c *Client) handleFailure(msg protocol.Message) error {
863
869
"role" , "client" ,
864
870
"connection_id" , c .callbackContext .ConnectionId .String (),
865
871
)
872
+ // Check for shutdown
873
+ select {
874
+ case <- c .Protocol .DoneChan ():
875
+ return protocol .ProtocolShuttingDownError
876
+ default :
877
+ }
866
878
msgFailure := msg .(* MsgFailure )
867
879
switch msgFailure .Failure {
868
880
case AcquireFailurePointTooOld :
@@ -883,6 +895,12 @@ func (c *Client) handleResult(msg protocol.Message) error {
883
895
"role" , "client" ,
884
896
"connection_id" , c .callbackContext .ConnectionId .String (),
885
897
)
898
+ // Check for shutdown
899
+ select {
900
+ case <- c .Protocol .DoneChan ():
901
+ return protocol .ProtocolShuttingDownError
902
+ default :
903
+ }
886
904
msgResult := msg .(* MsgResult )
887
905
c .queryResultChan <- msgResult .Result
888
906
return nil
Original file line number Diff line number Diff line change @@ -155,6 +155,12 @@ func (c *Client) handleAcceptTx() error {
155
155
"role" , "client" ,
156
156
"connection_id" , c .callbackContext .ConnectionId .String (),
157
157
)
158
+ // Check for shutdown
159
+ select {
160
+ case <- c .Protocol .DoneChan ():
161
+ return protocol .ProtocolShuttingDownError
162
+ default :
163
+ }
158
164
c .submitResultChan <- nil
159
165
return nil
160
166
}
@@ -167,6 +173,12 @@ func (c *Client) handleRejectTx(msg protocol.Message) error {
167
173
"role" , "client" ,
168
174
"connection_id" , c .callbackContext .ConnectionId .String (),
169
175
)
176
+ // Check for shutdown
177
+ select {
178
+ case <- c .Protocol .DoneChan ():
179
+ return protocol .ProtocolShuttingDownError
180
+ default :
181
+ }
170
182
msgRejectTx := msg .(* MsgRejectTx )
171
183
rejectErr , err := ledger .NewTxSubmitErrorFromCbor (msgRejectTx .Reason )
172
184
if err != nil {
Original file line number Diff line number Diff line change @@ -163,6 +163,12 @@ func (s *Server) handleReplyTxIds(msg protocol.Message) error {
163
163
"role" , "server" ,
164
164
"connection_id" , s .callbackContext .ConnectionId .String (),
165
165
)
166
+ // Check for shutdown
167
+ select {
168
+ case <- s .Protocol .DoneChan ():
169
+ return protocol .ProtocolShuttingDownError
170
+ default :
171
+ }
166
172
msgReplyTxIds := msg .(* MsgReplyTxIds )
167
173
s .requestTxIdsResultChan <- msgReplyTxIds .TxIds
168
174
return nil
@@ -176,6 +182,12 @@ func (s *Server) handleReplyTxs(msg protocol.Message) error {
176
182
"role" , "server" ,
177
183
"connection_id" , s .callbackContext .ConnectionId .String (),
178
184
)
185
+ // Check for shutdown
186
+ select {
187
+ case <- s .Protocol .DoneChan ():
188
+ return protocol .ProtocolShuttingDownError
189
+ default :
190
+ }
179
191
msgReplyTxs := msg .(* MsgReplyTxs )
180
192
s .requestTxsResultChan <- msgReplyTxs .Txs
181
193
return nil
You can’t perform that action at this time.
0 commit comments