Homework 1 forum

Callback function for private messages (GUI)

Picture of Gabriel Giamarchi
Callback function for private messages (GUI)
by Gabriel Giamarchi - Tuesday, 27 October 2020, 19:16

Last minute question due to manual testing :-)

When sending private messages to other nodes via the GUI (or cli since it will go the same controller) it seems to me that:

1. The private message shows on the sending node's log due to line `/controller.go:150`

2. [Unexpected] The private msg does *not* show on the receiver gossiper's log, because we only look at Simple/Rumor messages at `controller.go:234`.

Maybe this is a remnant of when students had to implement more parts of the the GUI? May we add code to the controller for manual testing? 

Picture of Pasindu Nivanthaka Tennage
Re: Callback function for private messages (GUI)
by Pasindu Nivanthaka Tennage - Wednesday, 28 October 2020, 13:57


Yes you are right, this is a slight issue with the code we provided. As a work around, I suggest you to do the following, upon receiving the private message at destination.

rumourMessage := RumorMessage{

Origin: priv.Origin,

ID:     priv.ID,

Text:   priv.Text,


if g.callback != nil {

g.callback(g.identifier, GossipPacket{Rumor: &rumourMessage})


Hope this answers your question