Add InfoHash.HexString convenience
This commit is contained in:
parent
8a0be03eec
commit
18d6f81184
5
misc.go
5
misc.go
|
@ -3,6 +3,7 @@ package torrent
|
||||||
import (
|
import (
|
||||||
"crypto"
|
"crypto"
|
||||||
"errors"
|
"errors"
|
||||||
|
"fmt"
|
||||||
"math/rand"
|
"math/rand"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
@ -32,6 +33,10 @@ func (ih *InfoHash) AsString() string {
|
||||||
return string(ih[:])
|
return string(ih[:])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (ih *InfoHash) HexString() string {
|
||||||
|
return fmt.Sprintf("%x", ih[:])
|
||||||
|
}
|
||||||
|
|
||||||
type piece struct {
|
type piece struct {
|
||||||
Hash pieceSum
|
Hash pieceSum
|
||||||
PendingChunkSpecs map[chunkSpec]struct{}
|
PendingChunkSpecs map[chunkSpec]struct{}
|
||||||
|
|
|
@ -67,3 +67,11 @@ func TestAppendToCopySlice(t *testing.T) {
|
||||||
t.FailNow()
|
t.FailNow()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestTorrentString(t *testing.T) {
|
||||||
|
tor := &torrent{}
|
||||||
|
s := tor.InfoHash.HexString()
|
||||||
|
if s != "0000000000000000000000000000000000000000" {
|
||||||
|
t.FailNow()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue