mirror of
https://github.com/libp2p/go-libp2p-peerstore.git
synced 2024-12-28 23:50:12 +08:00
support extracting inlined public keys
Technically, the caller can do this but this is more convenient.
This commit is contained in:
parent
2c122745dc
commit
3f5b1a304a
@ -27,9 +27,9 @@
|
||||
},
|
||||
{
|
||||
"author": "whyrusleeping",
|
||||
"hash": "QmaPbCnUMBohSGo3KnxEa2bHqyJVVeEEcwtqJAYxerieBo",
|
||||
"hash": "Qme1knMqwt1hKZbc1BmQFmnm9f36nyQGwXxPGVpVJ9rMK5",
|
||||
"name": "go-libp2p-crypto",
|
||||
"version": "1.5.0"
|
||||
"version": "1.6.2"
|
||||
},
|
||||
{
|
||||
"author": "jbenet",
|
||||
@ -45,9 +45,9 @@
|
||||
},
|
||||
{
|
||||
"author": "whyrusleeping",
|
||||
"hash": "QmZoWKhxUmZ2seW4BzX6fJkNR8hh9PsGModr7q171yq2SS",
|
||||
"hash": "QmWxGnWZcUNVtpMk8jjX13pK1WT9jJnKQtEfvkGdxSMVRu",
|
||||
"name": "go-libp2p-peer",
|
||||
"version": "2.2.3"
|
||||
"version": "2.3.1"
|
||||
},
|
||||
{
|
||||
"author": "multiformats",
|
||||
|
@ -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
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user