Skip to content

Feature/vote for new epoche#1

Merged
Sorizen merged 11 commits intomasterfrom
feature/vote-for-new-epoche
May 17, 2023
Merged

Feature/vote for new epoche#1
Sorizen merged 11 commits intomasterfrom
feature/vote-for-new-epoche

Conversation

@Sorizen
Copy link
Owner

@Sorizen Sorizen commented May 15, 2023

No description provided.

pala.js Outdated
if(item) {
acc += 1
}
return acc

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
)

Copy link
Owner Author

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) &&

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
) {

Copy link
Owner Author

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)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

split into a line

Copy link
Owner Author

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] =

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
}

Copy link
Owner Author

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));

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

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@Sorizen Sorizen merged commit cd7d2d3 into master May 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants