]> Sergey Matveev's repositories - btrtrc.git/blob - peerid.go
Add some helpful comments to type PeerID
[btrtrc.git] / peerid.go
1 package torrent
2
3 import (
4         "encoding/hex"
5 )
6
7 // Peer client ID.
8 type PeerID [20]byte
9
10 // Pretty prints the ID as hex, except parts that adher to the Peer ID
11 // Conventions of BEP 20.
12 func (me PeerID) String() string {
13         if me[0] == '-' && me[7] == '-' {
14                 return string(me[:8]) + hex.EncodeToString(me[8:])
15         }
16         return hex.EncodeToString(me[:])
17 }