mirror of
https://github.com/GopeedLab/gopeed.git
synced 2026-11-18 14:23:42 +00:00
feat: peer wire protocol实现
This commit is contained in:
1 parent
7bb3e38b21
commit
ee4ff7dd8b
13 files changed
+212
-165
No files matched your search
@@ -66,6 +66,17 @@ func (ps *pieces) size() int {
|
||||
return len(ps.arr)
|
||||
}
|
||||
|
||||
func (ps *pieces) isDone() bool {
|
||||
ps.rw.RLock()
|
||||
defer ps.rw.RUnlock()
|
||||
for _, s := range ps.arr {
|
||||
if s.state != stateFinished {
|
||||
return false
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
// 指定piece下的某个block是否下载完成
|
||||
func (ps *pieces) isBlockDownloaded(pieceIndex int, blockIndex int) bool {
|
||||
return ps.arr[pieceIndex].blocks.ContainsInt(blockIndex)
|
||||
|
||||
Reference in new issue
Block a user