mirror of
https://github.com/GopeedLab/gopeed.git
synced 2026-11-15 12:53:41 +00:00
单个peer的文件下载实现
This commit is contained in:
1 parent
fe0138440f
commit
15a4b6ddc4
9 files changed
+179
-48
No files matched your search
@@ -29,14 +29,14 @@ type Message struct {
|
||||
ID ID
|
||||
}
|
||||
|
||||
func (msg Message) Encode() []byte {
|
||||
func (msg *Message) Encode() []byte {
|
||||
buf := make([]byte, 5)
|
||||
binary.BigEndian.PutUint32(buf, msg.Length)
|
||||
buf[4] = byte(msg.ID)
|
||||
return buf
|
||||
}
|
||||
|
||||
func (msg Message) Decode(buf []byte) {
|
||||
func (msg *Message) Decode(buf []byte) {
|
||||
msg.Length = binary.BigEndian.Uint32(buf)
|
||||
msg.ID = ID(buf[4])
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user