1
0
mirror of https://github.com/veggiedefender/torrent-client.git synced 2025-11-06 09:29:16 +02:00

Separate bitfield into its own package

This commit is contained in:
Jesse
2019-12-29 20:24:06 -05:00
parent 353d112e4d
commit 3b7eb1da70
5 changed files with 66 additions and 56 deletions

View File

@@ -7,6 +7,8 @@ import (
"strconv"
"time"
"github.com/veggiedefender/torrent-client/bitfield"
"github.com/veggiedefender/torrent-client/message"
"github.com/veggiedefender/torrent-client/handshake"
@@ -18,7 +20,7 @@ type client struct {
peerID [20]byte
conn net.Conn
reader *bufio.Reader
bitfield message.Bitfield
bitfield bitfield.Bitfield
choked bool
}
@@ -39,7 +41,7 @@ func completeHandshake(conn net.Conn, r *bufio.Reader, infohash, peerID [20]byte
return res, nil
}
func recvBitfield(conn net.Conn, r *bufio.Reader) (message.Bitfield, error) {
func recvBitfield(conn net.Conn, r *bufio.Reader) (bitfield.Bitfield, error) {
conn.SetDeadline(time.Now().Local().Add(5 * time.Second))
defer conn.SetDeadline(time.Time{}) // Disable the deadline