-
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 sender id to message #207
Conversation
broken, one sec... |
ok, I believe this is a more correct implementation. This isn't ready to be merged, it was mostly opened to show a possible implementation. Also, I did not write any tests. After discussion, I'm happy to create a PR that could be ready for merge. |
@@ -11,3 +11,5 @@ require ( | |||
github.com/multiformats/go-multistream v0.1.0 | |||
github.com/whyrusleeping/timecache v0.0.0-20160911033111-cfcb2f1abfee | |||
) | |||
|
|||
go 1.13 |
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 didn't do this. It must've been added via go?
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's done automatically be go; please remove this line.
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.
Not sure if we want that, see notes on exposure.
@@ -135,12 +135,17 @@ type PubSubRouter interface { | |||
|
|||
type Message struct { | |||
*pb.Message | |||
senderID peer.ID |
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 available in the RPC
struct and will be exposed to routers in the refactoring in #199.
It is also visible to validators as it is passed in the validation function.
@@ -11,3 +11,5 @@ require ( | |||
github.com/multiformats/go-multistream v0.1.0 | |||
github.com/whyrusleeping/timecache v0.0.0-20160911033111-cfcb2f1abfee | |||
) | |||
|
|||
go 1.13 |
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's done automatically be go; please remove this line.
To clarify, I don't think this is relevant (the direct source of the message) to subscribers, as it is entirely non deterministic. |
Ah yes, I agree! I didn't realize it was already made available on the validator. That worked! Thanks! Closing... |
Note that we did end up adding it in #218, turns out it is needed for filecoin. |
Unless I'm mistaken, there's no way to get the sender ID from a message.
msg.GetFrom()
returns the originator's id, not the most recent sender. There could be use cases where knowing who sent this message is valuable. For instance, I'm building a small benchmark tool and I need to calculate last delivery hop. I do so by logging recipient host id and sender id. My analyzer then parses the logs and calculates each message path.I don't know if my simple implementation accomplishes this goal correctly or if there is a better way but would love to hear your thoughts.
Thanks!