Heartbeat mechanism in Test_HW2_Scenario

Heartbeat mechanism in Test_HW2_Scenario

by Wanhao Zhou -
Number of replies: 2

Hello,

I have a question on the heartbeat mechanism in Test_HW2_Scenario.

In the test setup, we have the following comments:

// at least every peer will send a heartbeat message on start,
// which will make everyone to have an entry in its routing
// table to every one else, thanks to the antientropy.

In my previous implementation of the heartbeat mechanism, it will start a goroutine when we call Start() on the node. The goroutine searches for a random neighbor and periodically sends the heartbeat message.

In this test, the nodes will start automatically when we initiate them, for example,

nodeA := z.NewTestNode(t, peerFac, transp, "127.0.0.1:0", opts...)

This means that only after the nodes have already started, the routing tables are updated with AddPeer() function.

I tried to run with this setup, and it is very likely that when the nodes try to send the first heartbeat message, they cannot find any neighbor because the routing tables are updated later. 

My question is: how can we ensure what is said in the comments that "at least every peer will send a heartbeat message on start", considering AddPeer() is called later? A hack would be to wait for, say 1 second, and then trigger the heartbeat when starting the node, but I guess this is not intended.


Best,

Wanhao

In reply to Wanhao Zhou

Re: Heartbeat mechanism in Test_HW2_Scenario

by Yuchen Qian -
I would encourge you to think again how the anti-entropy mechanism works...
In reply to Yuchen Qian

Re: Heartbeat mechanism in Test_HW2_Scenario

by Wanhao Zhou -
Many thanks for the answer. There was some misunderstanding on the heartbeat :)