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
f13a4fc1
Commit
f13a4fc1
authored
Apr 05, 2022
by
djq2
Browse files
moving
parent
53f22ac7
Changes
1
Hide whitespace changes
Inline
Side-by-side
mp2/src/raft/raft.go
View file @
f13a4fc1
...
...
@@ -238,8 +238,20 @@ func (rf *Raft) AppendEntries(args *AppendEntriesArgs, reply *AppendEntriesReply
}
}
else
{
//add else statment later to handle optimization
reply
.
Success
=
false
if
args
.
PrevLogIndex
>=
len
(
rf
.
log
)
{
reply
.
ConflictIdx
=
len
(
rf
.
log
)
-
1
reply
.
ConflictTerm
=
-
1
}
else
{
wrongTerm
:=
rf
.
log
[
args
.
PrevLogIndex
]
.
Term
reply
.
ConflictTerm
=
wrongTerm
for
i
:=
0
;
i
<
len
(
rf
.
log
);
i
++
{
if
rf
.
log
[
i
]
.
Term
==
reply
.
ConflictTerm
{
reply
.
ConflictIdx
=
i
break
}
}
}
}
reply
.
Term
=
rf
.
currentTerm
...
...
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