Skip to content

Commit 0d5faa2

Browse files
authored
Merge pull request #38 from cloudstruct/feature/server-handshake
Signal that the handshake is complete when acting as server
2 parents 75a95e7 + 1336cee commit 0d5faa2

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

cmd/go-ouroboros-network/server.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,5 +79,7 @@ func testServer(f *globalFlags) {
7979
if err != nil {
8080
fmt.Printf("ERROR: %s\n", err)
8181
}
82+
fmt.Printf("handshake completed...disconnecting\n")
83+
conn.Close()
8284
}
8385
}

protocol/handshake/handshake.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,11 +121,16 @@ func (h *Handshake) handleProposeVersions(msgGeneric protocol.Message) error {
121121
}
122122
if highestVersion > 0 {
123123
resp := NewMsgAcceptVersion(highestVersion, versionData)
124-
return h.proto.SendMessage(resp, true)
124+
if err := h.proto.SendMessage(resp, true); err != nil {
125+
return err
126+
}
127+
h.Version = highestVersion
128+
h.Finished <- true
129+
return nil
125130
} else {
126131
// TODO: handle failures
127132
// https://github.com/cloudstruct/go-ouroboros-network/issues/32
128-
return nil
133+
return fmt.Errorf("handshake failed, but we don't yet support this")
129134
}
130135
}
131136

0 commit comments

Comments
 (0)