fix broken WithMessageAuthor option

This commit is contained in:
vyzo 2020-04-23 15:33:19 +03:00
parent 1246e80812
commit 4f45d455f8
1 changed files with 2 additions and 1 deletions

View File

@ -308,13 +308,14 @@ func WithMessageSigning(enabled bool) Option {
// must be available in the host's peerstore.
func WithMessageAuthor(author peer.ID) Option {
return func(p *PubSub) error {
author := author
if author == "" {
author = p.host.ID()
}
if p.signKey != nil {
newSignKey := p.host.Peerstore().PrivKey(author)
if newSignKey == nil {
return fmt.Errorf("can't sign for peer %s: no private key", p.signID)
return fmt.Errorf("can't sign for peer %s: no private key", author)
}
p.signKey = newSignKey
}