-
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
add ValidatorData field to Message #231
Conversation
Useful for passing data from the validation to the application.
Thanks @vyzo ! |
@@ -151,6 +151,7 @@ type PubSubRouter interface { | |||
type Message struct { | |||
*pb.Message | |||
ReceivedFrom peer.ID | |||
VaidatorData interface{} |
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.
@vyzo where is this field set, did you forget to add a file?
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.
Also, is this just a convenience thing since the data is already available by emitting data from the validators?
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.
Yes, this is for validators to set, and for subscribers to consume. Basically, I'd like to avoid having to unmarshal things twice
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.
it is initialized to nil
when we construct the message; it's for use from validators, they can set it to pass data to the application (eg. the unmarshalled payload to avoid unmarshalling twice).
This is a filecoin ask.
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.
@vyzo Ok, no problem with convenience functions.
Although, I'd like to point out that in less than 30 minutes you've just passed a change that causes problems if there are multiple validators for a single message since they may both clobber the ValidateData
field. There is also no documentation for this behavior.
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 completely breaks the abstraction of pubsub as a shared service. There's no reason we can't have validators return additional data (along with an error) and have the validation subsystem collect all the extra validation data.
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.
So what's the proper usage of this field?
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.
It allows the validation to pass data to the application; one common usage (eg in lotus) is to pass the decoded message to avoid parsing and decoding twice.
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.
I get that and that’s my intent as well , just seems like there was an extended convo about it and wondering if any issues or assumptions need to be held when using it this way
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.
The issue in the convo was about multiple validators competing for the coveted field, but it's a very rare occurrence to have a message that validates in multiple topics.
Useful for passing data from the validation to the application.