refactor: impl piece state with bitmap

This commit is contained in:
liwei committed 2020-03-11 12:24:45 +08:00
1 parent b823dfbb36
commit 1d2f38d7ae
5 files changed
+79 -146

No files matched your search

+13
View File
@@ -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())
}