Skip to content

Commit

Permalink
Merge pull request stellar#2216 from marta-lokhova/scp_consistent_naming
Browse files Browse the repository at this point in the history
Improve naming consistency of federated voting functions

Reviewed-by: MonsieurNicolas
  • Loading branch information
latobarita committed Aug 9, 2019
2 parents 593d5d0 + 3bf757e commit 46d5df0
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 15 deletions.
21 changes: 10 additions & 11 deletions src/scp/BallotProtocol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -790,7 +790,7 @@ BallotProtocol::updateCurrentIfNeeded(SCPBallot const& h)
}

bool
BallotProtocol::attemptPreparedAccept(SCPStatement const& hint)
BallotProtocol::attemptAcceptPrepared(SCPStatement const& hint)
{
if (mPhase != SCP_PHASE_PREPARE && mPhase != SCP_PHASE_CONFIRM)
{
Expand Down Expand Up @@ -868,18 +868,18 @@ BallotProtocol::attemptPreparedAccept(SCPStatement const& hint)
std::bind(&BallotProtocol::hasPreparedBallot, ballot, _1));
if (accepted)
{
return setPreparedAccept(ballot);
return setAcceptPrepared(ballot);
}
}

return false;
}

bool
BallotProtocol::setPreparedAccept(SCPBallot const& ballot)
BallotProtocol::setAcceptPrepared(SCPBallot const& ballot)
{
if (Logging::logTrace("SCP"))
CLOG(TRACE, "SCP") << "BallotProtocol::setPreparedAccept"
CLOG(TRACE, "SCP") << "BallotProtocol::setAcceptPrepared"
<< " i: " << mSlot.getSlotIndex()
<< " b: " << mSlot.getSCP().ballotToStr(ballot);

Expand Down Expand Up @@ -911,7 +911,7 @@ BallotProtocol::setPreparedAccept(SCPBallot const& ballot)
}

bool
BallotProtocol::attemptPreparedConfirmed(SCPStatement const& hint)
BallotProtocol::attemptConfirmPrepared(SCPStatement const& hint)
{
if (mPhase != SCP_PHASE_PREPARE)
{
Expand Down Expand Up @@ -988,7 +988,7 @@ BallotProtocol::attemptPreparedConfirmed(SCPStatement const& hint)
}
}
}
res = setPreparedConfirmed(newC, newH);
res = setConfirmPrepared(newC, newH);
}
return res;
}
Expand Down Expand Up @@ -1028,11 +1028,10 @@ BallotProtocol::commitPredicate(SCPBallot const& ballot, Interval const& check,
}

bool
BallotProtocol::setPreparedConfirmed(SCPBallot const& newC,
SCPBallot const& newH)
BallotProtocol::setConfirmPrepared(SCPBallot const& newC, SCPBallot const& newH)
{
if (Logging::logTrace("SCP"))
CLOG(TRACE, "SCP") << "BallotProtocol::setPreparedConfirmed"
CLOG(TRACE, "SCP") << "BallotProtocol::setConfirmPrepared"
<< " i: " << mSlot.getSlotIndex()
<< " h: " << mSlot.getSCP().ballotToStr(newH);

Expand Down Expand Up @@ -1858,9 +1857,9 @@ BallotProtocol::advanceSlot(SCPStatement const& hint)

bool didWork = false;

didWork = attemptPreparedAccept(hint) || didWork;
didWork = attemptAcceptPrepared(hint) || didWork;

didWork = attemptPreparedConfirmed(hint) || didWork;
didWork = attemptConfirmPrepared(hint) || didWork;

didWork = attemptAcceptCommit(hint) || didWork;

Expand Down
8 changes: 4 additions & 4 deletions src/scp/BallotProtocol.h
Original file line number Diff line number Diff line change
Expand Up @@ -143,15 +143,15 @@ class BallotProtocol
// output: returns true if the state was updated.

// step 1 and 5 from the SCP paper
bool attemptPreparedAccept(SCPStatement const& hint);
bool attemptAcceptPrepared(SCPStatement const& hint);
// prepared: ballot that should be prepared
bool setPreparedAccept(SCPBallot const& prepared);
bool setAcceptPrepared(SCPBallot const& prepared);

// step 2+3+8 from the SCP paper
// ballot is the candidate to record as 'confirmed prepared'
bool attemptPreparedConfirmed(SCPStatement const& hint);
bool attemptConfirmPrepared(SCPStatement const& hint);
// newC, newH : low/high bounds prepared confirmed
bool setPreparedConfirmed(SCPBallot const& newC, SCPBallot const& newH);
bool setConfirmPrepared(SCPBallot const& newC, SCPBallot const& newH);

// step (4 and 6)+8 from the SCP paper
bool attemptAcceptCommit(SCPStatement const& hint);
Expand Down

0 comments on commit 46d5df0

Please sign in to comment.