简单实现peer wire protocol协议

This commit is contained in:
liwei committed 2019-11-01 15:05:25 +08:00
1 parent ae1c605143
commit fb45066228
13 files changed
+859 -404

No files matched your search

+40
View File
@@ -0,0 +1,40 @@
package torrent
import (
"fmt"
"github.com/monkeyWie/gopeed/down/bt/peer"
"testing"
)
func Test_PeerPool(t *testing.T) {
pool := newPeerPool()
pool.put([]peer.Peer{
{
IP: 0,
Port: 0,
},
{
IP: 1,
Port: 0,
},
{
IP: 2,
Port: 0,
},
{
IP: 3,
Port: 0,
},
{
IP: 4,
Port: 0,
},
})
get := pool.get()
pool.release(get)
pool.remove(get)
for i := 0; i < 5; i++ {
fmt.Println(pool.get())
}
fmt.Println(pool.get())
}