Skip to content

Commit

Permalink
Merge pull request #27 from libp2p/feat/inline-pk
Browse files Browse the repository at this point in the history
add support for extracting inlined public keys
  • Loading branch information
Stebalien committed Apr 16, 2018
2 parents fd4d308 + 6ef12b5 commit 72e0087
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions p2p/host/peerstore/peerstore.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,15 @@ func (kb *keybook) PubKey(p peer.ID) ic.PubKey {
kb.RLock()
pk := kb.pks[p]
kb.RUnlock()
if pk != nil {
return pk
}
pk, err := p.ExtractPublicKey()
if err == nil && pk != nil {
kb.Lock()
kb.pks[p] = pk
kb.Unlock()
}
return pk
}

Expand Down

0 comments on commit 72e0087

Please sign in to comment.