-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature/vote for new epoche #1
Conversation
pala.js
Outdated
if(item) { | ||
acc += 1 | ||
} | ||
return acc |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.reduce(
(acc, item) => item ? acc + 1 : acc,
MIN_COUNT_OF_VOTES
)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
pala.js
Outdated
server.electionAlarm = makeElectionAlarm(model.time); | ||
server.term += 1; | ||
const isLeaderExist = model.servers.some(item => item.state === SERVER_STATES.leader) | ||
if ((server.state === SERVER_STATES.follower) && |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (server.state === SERVER_STATES.follower &&
server.electionAlarm <= model.time &&
!isLeaderExist
) {
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
pala.js
Outdated
} | ||
}; | ||
|
||
const clearServer = (model, server) => { | ||
server.votedFor = null | ||
server.electionAlarm = server.state === SERVER_STATES.leader || server.state === SERVER_STATES.stopped ? 0 : makeElectionAlarm(model.time) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
split into a line
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
pala.js
Outdated
server.votedFor = request.from; | ||
server.electionAlarm = makeElectionAlarm(model.time); | ||
server.peers.forEach(peerId => { | ||
server.voteGranted[peerId] = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const isVoteGranted = server.term === request.term &&
server.id === request.to &&
peerId === request.from
if (isVoteGranted) {
server.voteGranted[peerId] = isVoteGranted
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done, but need to talk
script.js
Outdated
peers.push(j); | ||
} | ||
state.current.servers.push(raft.server(i, peers)); | ||
state.current.servers.push(pala.server(i, peers, i === START_PROPOSER_IDX, i === START_PROPOSER_IDX ? START_PROPOSER_IDX : undefined)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i === START_PROPOSER_IDX
to const
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
No description provided.