diff options
| author | jet2tlf <jet2tlf@gmail.com> | 2024-06-03 17:45:17 +0000 |
|---|---|---|
| committer | jet2tlf <jet2tlf@gmail.com> | 2024-06-03 17:45:17 +0000 |
| commit | b01c839940e6ea22ddc28aa0c975d3cd3da69e72 (patch) | |
| tree | 3f1811c4980d6fe24bdd0cf78a12acb5a696b1bf /cmd | |
| parent | 6091bea631659a2e5d152726f3581ca2d1bd235c (diff) | |
| download | bittorrent-go-b01c839940e6ea22ddc28aa0c975d3cd3da69e72.tar.gz bittorrent-go-b01c839940e6ea22ddc28aa0c975d3cd3da69e72.zip | |
codecrafters submit [skip ci]
Diffstat (limited to 'cmd')
| -rw-r--r-- | cmd/mybittorrent/main.go | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/cmd/mybittorrent/main.go b/cmd/mybittorrent/main.go index d8014e7..5eecb20 100644 --- a/cmd/mybittorrent/main.go +++ b/cmd/mybittorrent/main.go @@ -36,12 +36,22 @@ func main() { panic(err) } + fmt.Printf("Tracker URL: %s\n", meta.Announce) + fmt.Printf("Length: %d\n", meta.Info.Length) + sha := sha1.New() if err = bencode.Marshal(sha, meta.Info); err != nil { panic(err) } - fmt.Printf("Tracker URL: %s\nLength: %d\nInfo Hash: %x", meta.Announce, meta.Info.Length, sha.Sum(nil)) + fmt.Printf("Info Hash: %x", sha.Sum(nil)) + + fmt.Printf("Piece Length: %d\n", meta.Info.PieceLength) + fmt.Println("Piece Hashes:") + + for i := 0; i < len(meta.Info.Pieces); i += 20 { + fmt.Printf("%x\n", meta.Info.Pieces[i:i+20]) + } default: fmt.Println("Unknown command: " + command) |