p2p, p2p/discover, p2p/nat: rework logging using context keys

This commit is contained in:
Felix Lange
2017-02-24 09:58:04 +01:00
parent 35e8308bf7
commit 96ae35e2ac
11 changed files with 171 additions and 151 deletions

View File

@ -221,6 +221,11 @@ func (n NodeID) GoString() string {
return fmt.Sprintf("discover.HexID(\"%x\")", n[:])
}
// TerminalString returns a shortened hex string for terminal logging.
func (n NodeID) TerminalString() string {
return hex.EncodeToString(n[:8])
}
// HexID converts a hex string to a NodeID.
// The string may be prefixed with 0x.
func HexID(in string) (NodeID, error) {