raft4s icon indicating copy to clipboard operation
raft4s copied to clipboard

Result types mismatch in the Follower NodeState

Open hepengzheng opened this issue 1 year ago • 1 comments

Hi! I'm not very familiar with Scala and I find these lines weird in FollowerNode.scala:

    if (msg.term < currentTerm) {
      (this, (VoteResponse(node, msg.term, false)))
    } else if (votedFor.isEmpty || votedFor.contains(msg.nodeId)) {
      if (msg.lastLogIndex >= logState.lastLogIndex && msg.lastLogTerm >= logState.lastLogTerm.getOrElse(0L)) {
        (VoteResponse(node, msg.term, true), List(StoreState))
      } else {
        (this, (VoteResponse(node, msg.term, false)))
      }
    }

As the the method is declared to return type (NodeState, (VoteResponse, List[Action])). @alirezameskin

hepengzheng avatar Oct 21 '23 16:10 hepengzheng