network: move SendVersion() to the Peer
Only leave server-specific `getVersionMsg()` in the Server, all the other logic is peer-related.
This commit is contained in:
parent
9befd8de99
commit
1f672e0da7
6 changed files with 26 additions and 20 deletions
|
@ -117,7 +117,7 @@ func (p *TCPPeer) handleConn() {
|
|||
|
||||
go p.handleQueues()
|
||||
// When a new peer is connected we send out our version immediately.
|
||||
err = p.server.sendVersion(p)
|
||||
err = p.SendVersion()
|
||||
if err == nil {
|
||||
r := io.NewBinReaderFromIO(p.conn)
|
||||
for {
|
||||
|
@ -235,7 +235,8 @@ func (p *TCPPeer) Handshaked() bool {
|
|||
}
|
||||
|
||||
// SendVersion checks for the handshake state and sends a message to the peer.
|
||||
func (p *TCPPeer) SendVersion(msg *Message) error {
|
||||
func (p *TCPPeer) SendVersion() error {
|
||||
msg := p.server.getVersionMsg()
|
||||
p.lock.Lock()
|
||||
defer p.lock.Unlock()
|
||||
if p.handShake&versionSent != 0 {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue