support extracting inlined public keys

Technically, the caller can do this but this is more convenient.
This commit is contained in:
Steven Allen 2018-04-16 13:17:06 +09:00
parent 2c122745dc
commit 3f5b1a304a
2 changed files with 13 additions and 4 deletions

View File

@ -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",

View File

@ -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
}