From 3f5b1a304aee62c4175ccd6b2bc1a30e2e320af5 Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Mon, 16 Apr 2018 13:17:06 +0900 Subject: [PATCH] support extracting inlined public keys Technically, the caller can do this but this is more convenient. --- package.json | 8 ++++---- peerstore.go | 9 +++++++++ 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index 214541d..cedf993 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/peerstore.go b/peerstore.go index d0fe38c..abfdeae 100644 --- a/peerstore.go +++ b/peerstore.go @@ -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 }