func PeerNameFromString(nameStr string) (PeerName, error) {
	var a, b, c, d, e, f uint64

	match := func(format string, args ...interface{}) bool {
		a, b, c, d, e, f = 0, 0, 0, 0, 0, 0
		n, err := fmt.Sscanf(nameStr+"\000", format+"\000", args...)
		return err == nil && n == len(args)
	}

	switch {
	case match("%2x:%2x:%2x:%2x:%2x:%2x", &a, &b, &c, &d, &e, &f):
	case match("::%2x:%2x:%2x:%2x", &c, &d, &e, &f):
	case match("%2x::%2x:%2x:%2x", &a, &d, &e, &f):
	case match("%2x:%2x::%2x:%2x", &a, &b, &e, &f):
	case match("%2x:%2x:%2x::%2x", &a, &b, &c, &f):
	case match("%2x:%2x:%2x:%2x::", &a, &b, &c, &d):
	case match("::%2x:%2x:%2x", &d, &e, &f):
	case match("%2x::%2x:%2x", &a, &e, &f):
	case match("%2x:%2x::%2x", &a, &b, &f):
	case match("%2x:%2x:%2x::", &a, &b, &c):
	case match("::%2x:%2x", &e, &f):
	case match("%2x::%2x", &a, &f):
	case match("%2x:%2x::", &a, &b):
	case match("::%2x", &f):
	case match("%2x::", &a):
	default:
		return UnknownPeerName, fmt.Errorf("invalid peer name format: %q", nameStr)
	}

	return PeerName(a<<40 | b<<32 | c<<24 | d<<16 | e<<8 | f), nil
}
func PeerNameFromString(nameStr string) (PeerName, error) {
	var a, b, c, d, e, f uint64

	match := func(format string, args ...interface{}) bool {
		a, b, c, d, e, f = 0, 0, 0, 0, 0, 0
		n, err := fmt.Sscanf(nameStr+"\000", format+"\000", args...)
		return err == nil && n == len(args)
	}

	switch {
	case match("%2x:%2x:%2x:%2x:%2x:%2x", &a, &b, &c, &d, &e, &f):
	case match("::%2x:%2x:%2x:%2x", &c, &d, &e, &f):
	case match("%2x::%2x:%2x:%2x", &a, &d, &e, &f):
	case match("%2x:%2x::%2x:%2x", &a, &b, &e, &f):
	case match("%2x:%2x:%2x::%2x", &a, &b, &c, &f):
	case match("%2x:%2x:%2x:%2x::", &a, &b, &c, &d):
	case match("::%2x:%2x:%2x", &d, &e, &f):
	case match("%2x::%2x:%2x", &a, &e, &f):
	case match("%2x:%2x::%2x", &a, &b, &f):
	case match("%2x:%2x:%2x::", &a, &b, &c):
	case match("::%2x:%2x", &e, &f):
	case match("%2x::%2x", &a, &f):
	case match("%2x:%2x::", &a, &b):
	case match("::%2x", &f):
	case match("%2x::", &a):
	default:
		return UnknownPeerName, fmt.Errorf("invalid peer name format: %q", nameStr)
	}

	return PeerName(a<<40 | b<<32 | c<<24 | d<<16 | e<<8 | f), nil
}
func PeerNameFromString ( nameStr string ) ( PeerName , error ) { var a , b , c , d , e , f uint64 match := func ( format string , args ... interface { } ) bool { a , b , c , d , e , f = 0 , 0 , 0 , 0 , 0 , 0 n , err := fmt . Sscanf ( nameStr + " \000 " , format + " \000 " , args ... ) return err == nil && n == len ( args ) } switch { case match ( " " , & a , & b , & c , & d , & e , & f ) : case match ( " " , & c , & d , & e , & f ) : case match ( " " , & a , & d , & e , & f ) : case match ( " " , & a , & b , & e , & f ) : case match ( " " , & a , & b , & c , & f ) : case match ( " " , & a , & b , & c , & d ) : case match ( " " , & d , & e , & f ) : case match ( " " , & a , & e , & f ) : case match ( " " , & a , & b , & f ) : case match ( " " , & a , & b , & c ) : case match ( " " , & e , & f ) : case match ( " " , & a , & f ) : case match ( " " , & a , & b ) : case match ( " " , & f ) : case match ( " " , & a ) : default : return UnknownPeerName , fmt . Errorf ( " " , nameStr ) } return PeerName ( a << 40 | b << 32 | c << 24 | d << 16 | e << 8 | f ) , nil }
// PeerNameFromString parses PeerName from a generic string.
PeerNameFromString parses PeerName from a generic string .