Skip to content

Commit 2d5a6e5

Browse files
authored
feat: add a timeout for handshake propose on server side (#583)
Fixes #582
1 parent c051f8e commit 2d5a6e5

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

protocol/handshake/server.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,12 @@ func NewServer(protoOptions protocol.ProtocolOptions, cfg *Config) *Server {
3737
Server: s,
3838
ConnectionId: protoOptions.ConnectionId,
3939
}
40+
// Update state map with timeout
41+
stateMap := StateMap.Copy()
42+
if entry, ok := stateMap[statePropose]; ok {
43+
entry.Timeout = s.config.Timeout
44+
stateMap[statePropose] = entry
45+
}
4046
protoConfig := protocol.ProtocolConfig{
4147
Name: ProtocolName,
4248
ProtocolId: ProtocolId,
@@ -46,7 +52,7 @@ func NewServer(protoOptions protocol.ProtocolOptions, cfg *Config) *Server {
4652
Role: protocol.ProtocolRoleServer,
4753
MessageHandlerFunc: s.handleMessage,
4854
MessageFromCborFunc: NewMsgFromCbor,
49-
StateMap: StateMap,
55+
StateMap: stateMap,
5056
InitialState: statePropose,
5157
}
5258
s.Protocol = protocol.New(protoConfig)

0 commit comments

Comments
 (0)