This is following #9 code review. Similarly to what we do in the follower, leaders and candidates should check if the node requesting a vote has the log at least as up-to-date as ours, otherwise we should not grant the vote.
If votedFor is null or candidateId, and candidate's log is at
least as up-to-date as receiver’s log, grant vote (§5.2, §5.4)
Additionally, looking at go code, RequestVote handling is exactly the same for all node types, so maybe it would be good to refactor that bit of state somehow, so that we can have a generic function for handling it?
I wouldn't mind taking a stab at this over the next week, just need a bit of time to setup a new machine a just bought...
This is following #9 code review. Similarly to what we do in the follower, leaders and candidates should check if the node requesting a vote has the log at least as up-to-date as ours, otherwise we should not grant the vote.
Additionally, looking at go code, RequestVote handling is exactly the same for all node types, so maybe it would be good to refactor that bit of state somehow, so that we can have a generic function for handling it?
I wouldn't mind taking a stab at this over the next week, just need a bit of time to setup a new machine a just bought...