Skip to content

Commit f221d8c

Browse files
authored
feat: support for client Done in TxSubmission (#1074)
Fixes #1073 Signed-off-by: Aurora Gaffney <[email protected]>
1 parent e9d725b commit f221d8c

File tree

2 files changed

+32
-1
lines changed

2 files changed

+32
-1
lines changed

protocol/txsubmission/client.go

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,17 @@ func (c *Client) handleRequestTxIds(msg protocol.Message) error {
124124
msgRequestTxIds.Req,
125125
)
126126
if err != nil {
127-
return err
127+
if !errors.Is(err, ErrStopServerProcess) {
128+
return err
129+
}
130+
if !msgRequestTxIds.Blocking {
131+
return errors.New("cannot stop server process during a non-blocking operation")
132+
}
133+
resp := NewMsgDone()
134+
if err := c.SendMessage(resp); err != nil {
135+
return err
136+
}
137+
return nil
128138
}
129139
resp := NewMsgReplyTxIds(txIds)
130140
if err := c.SendMessage(resp); err != nil {

protocol/txsubmission/error.go

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// Copyright 2025 Blink Labs Software
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
package txsubmission
16+
17+
import "errors"
18+
19+
// ErrStopServerProcess is used as a special return value from a RequestTxIds handler function to signify
20+
// that the server should stop asking for transactions. This should only be used when the request is blocking
21+
var ErrStopServerProcess = errors.New("stop server process")

0 commit comments

Comments
 (0)