mirror of
https://github.com/logos-messaging/go-libp2p-pubsub.git
synced 2026-01-07 15:23:08 +00:00
fix broken WithMessageAuthor option
This commit is contained in:
parent
1246e80812
commit
4f45d455f8
@ -308,13 +308,14 @@ func WithMessageSigning(enabled bool) Option {
|
|||||||
// must be available in the host's peerstore.
|
// must be available in the host's peerstore.
|
||||||
func WithMessageAuthor(author peer.ID) Option {
|
func WithMessageAuthor(author peer.ID) Option {
|
||||||
return func(p *PubSub) error {
|
return func(p *PubSub) error {
|
||||||
|
author := author
|
||||||
if author == "" {
|
if author == "" {
|
||||||
author = p.host.ID()
|
author = p.host.ID()
|
||||||
}
|
}
|
||||||
if p.signKey != nil {
|
if p.signKey != nil {
|
||||||
newSignKey := p.host.Peerstore().PrivKey(author)
|
newSignKey := p.host.Peerstore().PrivKey(author)
|
||||||
if newSignKey == nil {
|
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
|
p.signKey = newSignKey
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user