mirror of
https://github.com/GopeedLab/gopeed.git
synced 2026-11-10 02:20:28 +00:00
refactor: impl piece state with bitmap
This commit is contained in:
1 parent
b823dfbb36
commit
1d2f38d7ae
5 files changed
+79
-146
No files matched your search
@@ -3,6 +3,7 @@ package metainfo
|
||||
import (
|
||||
"encoding/hex"
|
||||
"fmt"
|
||||
"github.com/RoaringBitmap/roaring"
|
||||
"testing"
|
||||
)
|
||||
|
||||
@@ -17,3 +18,15 @@ func TestParseFromFile(t *testing.T) {
|
||||
fmt.Printf("%+v\n", metaInfo.Info.PieceLength)
|
||||
fmt.Printf("%+v\n", hex.EncodeToString(metaInfo.infoHash[:]))
|
||||
}
|
||||
|
||||
func TestParseFromFile2(t *testing.T) {
|
||||
a := 0b10010000
|
||||
b := 0b01111111
|
||||
fmt.Printf("%08b\n", (a&b)^b)
|
||||
|
||||
have := roaring.BitmapOf(0, 3)
|
||||
peer := roaring.BitmapOf(1, 2, 3, 4, 5, 6, 7)
|
||||
|
||||
need := roaring.Xor(roaring.And(have, peer), peer)
|
||||
fmt.Println(need.ToArray())
|
||||
}
|
||||
Reference in new issue
Block a user