Skip to content

peer short tags are improved #848

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Mar 5, 2015
Merged

peer short tags are improved #848

merged 3 commits into from
Mar 5, 2015

Conversation

techfreek
Copy link
Contributor

peer short tags are still the same length, but skips the first 2 characters which are identical sha256 peerIDs.

}
return fmt.Sprintf("<peer.ID %s>", pid[:maxRunes])
return fmt.Sprintf("<peer.ID %s>", pid[skip:maxRunes + skip])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this will panic if len(pid) == 0.

How about:

pid := id.Pretty()
if strings.HasPrefix(pid, "Qm") {
  pid = pid[2:]
}
maxRunes := 6
if len(pid) < maxRunes {
  maxRunes = len(pid) 
}
return fmt.Sprintf("<peer.ID %s>", pid[:maxRunes])

jbenet added a commit that referenced this pull request Mar 5, 2015
peer short tags are improved
@jbenet jbenet merged commit 2d16d25 into ipfs:master Mar 5, 2015
@jbenet
Copy link
Member

jbenet commented Mar 5, 2015

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants