Skip to content
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

Merged
merged 11 commits into from
May 17, 2023
Merged

Feature/vote for new epoche #1

merged 11 commits into from
May 17, 2023

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