Homework 1 forum

Callback clarification

Picture of Adrian Matthijs Christian Hamelink
Callback clarification
by Adrian Matthijs Christian Hamelink - Tuesday, 6 October 2020, 10:51

There was some confusion in the last homework about when the given callback function should be called.

We had to modify the SimpleMessage and change the relay address before calling the callback. This seemed a bit counterintuitive since the callback expects a gossip packet, and we then had to rewrap the simple message in a gossip packet after processing.

Is this still the case in HW1? If not, is it expected that we call the callback on the unprocessed gossip packet (eg. after unmarshalling but before Exec)? . In this latter case, the behaviour for the controller would be different for SimpleMessage. 

Picture of Pasindu Nivanthaka Tennage
Re: Callback clarification
by Pasindu Nivanthaka Tennage - Thursday, 8 October 2020, 11:43

Hey Adrian,

Thank you for your question, and please find the explanation below.

1. For the private messages, the call back should only be called when the destination node receives the message. And you should make a gossip packet which contains a rumor message to pass it to the controller via callback 

2. For rumor messages, the callback is called only after it has been delivered (meaning that if the conditions for delivering the messages depending on the sequence numbers are held). Here you call the callback with the initially received rumor message (not after processing). In first principals if we think, what we need to send to the client is; from whom we got this message, and who is the originator + message content.

Hope this is clear