2
0
mirror of synced 2025-02-24 14:48:27 +00:00
torrent/peerid.go
2018-01-25 13:14:37 +11:00

18 lines
345 B
Go

package torrent
import (
"encoding/hex"
)
// Peer client ID.
type PeerID [20]byte
// Pretty prints the ID as hex, except parts that adher to the Peer ID
// Conventions of BEP 20.
func (me PeerID) String() string {
if me[0] == '-' && me[7] == '-' {
return string(me[:8]) + hex.EncodeToString(me[8:])
}
return hex.EncodeToString(me[:])
}