Peers and paths

This commit is contained in:
Adam Ierymenko 2019-09-22 17:41:15 -07:00
parent ccc9be2d4d
commit 90d4d79828
No known key found for this signature in database
GPG key ID: C8877CF2D7A5D7F3
11 changed files with 153 additions and 23 deletions

View file

@ -123,9 +123,15 @@ func (id *Identity) PrivateKeyString() string {
// PublicKeyString returns the address and public key (identity.public contents).
// An empty string is returned if this identity is invalid or not initialized.
func (id *Identity) String() string {
if len(id.publicKey) == IdentityTypeC25519PublicKeySize {
s := fmt.Sprintf("%.10x:0:%x", id.address, id.publicKey)
return s
switch id.idtype {
case IdentityTypeC25519:
if len(id.publicKey) == IdentityTypeC25519PublicKeySize {
return fmt.Sprintf("%.10x:0:%x", id.address, id.publicKey)
}
case IdentityTypeP384:
if len(id.publicKey) == IdentityTypeP384PublicKeySize {
return fmt.Sprintf("%.10x:1:%s", uint64(id.address), base32StdLowerCase.EncodeToString(id.publicKey))
}
}
return ""
}