Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
djq2
ECE 428 - Distributed Systems
Commits
ce87fa4e
Commit
ce87fa4e
authored
Apr 01, 2022
by
djq2
Browse files
Close version
parent
6f9047eb
Changes
1
Hide whitespace changes
Inline
Side-by-side
mp2/src/raft/raft.go
View file @
ce87fa4e
...
...
@@ -272,11 +272,11 @@ func (rf *Raft) Follower() {
func
(
rf
*
Raft
)
Candidate
()
{
timeout
:=
time
.
Duration
((
750
+
(
rand
.
Int
()
%
150
)))
*
time
.
Millisecond
fmt
.
Println
(
strconv
.
Itoa
(
rf
.
me
)
+
"Initiated Election"
)
// fmt.Println(rf)
fmt
.
Println
()
if
rf
.
votedFor
.
term
>=
rf
.
currentTerm
+
1
{
go
rf
.
Follower
()
return
}
...
...
@@ -285,6 +285,8 @@ func (rf *Raft) Candidate() {
rf
.
state
=
"CANDIDATE"
rf
.
mu
.
Unlock
()
fmt
.
Println
(
strconv
.
Itoa
(
rf
.
me
)
+
"Initiated Election"
)
candStart
:=
time
.
Now
()
majority
:=
len
(
rf
.
peers
)
/
2
//set up vote args
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment