Add some helpful comments to type PeerID

This commit is contained in:
Matt Joiner 2018-01-25 13:14:37 +11:00
parent 51b3374015
commit d5f8440e7e
1 changed files with 3 additions and 0 deletions

View File

@ -4,8 +4,11 @@ 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:])