-
Notifications
You must be signed in to change notification settings - Fork 186
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Publishing option for signing a message with a custom private key #486
Conversation
iulianpascalau
commented
May 25, 2022
•
edited
Loading
edited
- added publishing option for signing a message with a custom private key
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks fine, but would it make more sense to introduce a topic option WithPublisher
and using that?
topic.go
Outdated
// (which can be cached) will improve the performance as it does not require the generation of the public key | ||
// and the resulting peer ID. | ||
// This method can be used as to be able to publish messages on the network without having a "real", connectable host. | ||
func (t *Topic) PublishWithSk(ctx context.Context, data []byte, signKey crypto.PrivKey, pid peer.ID, opts ...PubOpt) error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's not abbreviate the Sk and say PublishWithKey
or PublishWithSecretKey
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will refactor
I will explore that. I was on the verge of pushing a new commit for code duplication removal. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there are a couple of bugs, but otherwise looks good.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just some final nits and it is ready to merge.
topic_test.go
Outdated
@@ -920,3 +921,101 @@ func TestWithTopicMsgIdFunction(t *testing.T) { | |||
t.Fatal("msg ids are equal") | |||
} | |||
} | |||
|
|||
func TestTopic_PublishWithKeyInvalidParameters(t *testing.T) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we remove the underscore?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sure
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is the Elrond pattern used in tests :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
topic_test.go
Outdated
}) | ||
} | ||
|
||
func TestTopicRelay_PublishWithKey(t *testing.T) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
here too
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thank you!