@@ -31,8 +31,7 @@ var StateMap = protocol.StateMap{
3131 },
3232 },
3333 STATE_CONFIRM : protocol.StateMapEntry {
34- Agency : protocol .AGENCY_SERVER ,
35- Timeout : 5 * time .Second ,
34+ Agency : protocol .AGENCY_SERVER ,
3635 Transitions : []protocol.StateTransition {
3736 {
3837 MsgType : MESSAGE_TYPE_ACCEPT_VERSION ,
@@ -59,6 +58,7 @@ type Config struct {
5958 NetworkMagic uint32
6059 ClientFullDuplex bool
6160 FinishedFunc FinishedFunc
61+ Timeout time.Duration
6262}
6363
6464type FinishedFunc func (uint16 , bool ) error
@@ -74,7 +74,9 @@ func New(protoOptions protocol.ProtocolOptions, cfg *Config) *Handshake {
7474type HandshakeOptionFunc func (* Config )
7575
7676func NewConfig (options ... HandshakeOptionFunc ) Config {
77- c := Config {}
77+ c := Config {
78+ Timeout : 5 * time .Second ,
79+ }
7880 // Apply provided options functions
7981 for _ , option := range options {
8082 option (& c )
@@ -105,3 +107,9 @@ func WithFinishedFunc(finishedFunc FinishedFunc) HandshakeOptionFunc {
105107 c .FinishedFunc = finishedFunc
106108 }
107109}
110+
111+ func WithTimeout (timeout time.Duration ) HandshakeOptionFunc {
112+ return func (c * Config ) {
113+ c .Timeout = timeout
114+ }
115+ }
0 commit comments