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

Large ripple calc refactoring. #470

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
133 changes: 68 additions & 65 deletions Builds/VisualStudio2013/RippleD.vcxproj

Large diffs are not rendered by default.

76 changes: 41 additions & 35 deletions Builds/VisualStudio2013/RippleD.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,9 @@
<Filter Include="ripple\module\app\paths">
<UniqueIdentifier>{4A33F050-B4FA-BECE-FA9B-963BE4AAF1A0}</UniqueIdentifier>
</Filter>
<Filter Include="ripple\module\app\paths\cursor">
<UniqueIdentifier>{1ADC0318-326E-565A-CF79-DF72B8D889DB}</UniqueIdentifier>
</Filter>
<Filter Include="ripple\module\app\peers">
<UniqueIdentifier>{08C8AFC4-AE5D-8717-F687-1E7D1900FCC2}</UniqueIdentifier>
</Filter>
Expand Down Expand Up @@ -3282,45 +3285,15 @@
<ClInclude Include="..\..\src\ripple\module\app\node\SqliteFactory.h">
<Filter>ripple\module\app\node</Filter>
</ClInclude>
<ClCompile Include="..\..\src\ripple\module\app\paths\CalcNodeAdvance.cpp">
<Filter>ripple\module\app\paths</Filter>
</ClCompile>
<ClCompile Include="..\..\src\ripple\module\app\paths\CalcNodeDeliverFwd.cpp">
<Filter>ripple\module\app\paths</Filter>
</ClCompile>
<ClCompile Include="..\..\src\ripple\module\app\paths\CalcNodeDeliverRev.cpp">
<Filter>ripple\module\app\paths</Filter>
</ClCompile>
<ClInclude Include="..\..\src\ripple\module\app\paths\CalcState.h">
<Filter>ripple\module\app\paths</Filter>
</ClInclude>
<ClInclude Include="..\..\src\ripple\module\app\paths\Calculators.h">
<Filter>ripple\module\app\paths</Filter>
</ClInclude>
<ClCompile Include="..\..\src\ripple\module\app\paths\ComputeAccountLiquidityForward.cpp">
<Filter>ripple\module\app\paths</Filter>
</ClCompile>
<ClCompile Include="..\..\src\ripple\module\app\paths\ComputeAccountLiquidityReverse.cpp">
<Filter>ripple\module\app\paths</Filter>
</ClCompile>
<ClCompile Include="..\..\src\ripple\module\app\paths\ComputeLiquidity.cpp">
<Filter>ripple\module\app\paths</Filter>
</ClCompile>
<ClCompile Include="..\..\src\ripple\module\app\paths\ComputeOfferLiquidity.cpp">
<Filter>ripple\module\app\paths</Filter>
</ClCompile>
<ClCompile Include="..\..\src\ripple\module\app\paths\ComputeRippleLiquidity.cpp">
<Filter>ripple\module\app\paths</Filter>
</ClCompile>
<ClCompile Include="..\..\src\ripple\module\app\paths\Node.cpp">
<Filter>ripple\module\app\paths</Filter>
</ClCompile>
<ClInclude Include="..\..\src\ripple\module\app\paths\Node.h">
<Filter>ripple\module\app\paths</Filter>
</ClInclude>
<ClCompile Include="..\..\src\ripple\module\app\paths\PathNext.cpp">
<ClInclude Include="..\..\src\ripple\module\app\paths\NodeDirectory.h">
<Filter>ripple\module\app\paths</Filter>
</ClCompile>
</ClInclude>
<ClCompile Include="..\..\src\ripple\module\app\paths\PathRequest.cpp">
<Filter>ripple\module\app\paths</Filter>
</ClCompile>
Expand All @@ -3345,9 +3318,6 @@
<ClInclude Include="..\..\src\ripple\module\app\paths\Pathfinder.h">
<Filter>ripple\module\app\paths</Filter>
</ClInclude>
<ClInclude Include="..\..\src\ripple\module\app\paths\QualityConstraint.h">
<Filter>ripple\module\app\paths</Filter>
</ClInclude>
<ClCompile Include="..\..\src\ripple\module\app\paths\RippleCalc.cpp">
<Filter>ripple\module\app\paths</Filter>
</ClCompile>
Expand All @@ -3372,6 +3342,42 @@
<ClInclude Include="..\..\src\ripple\module\app\paths\Types.h">
<Filter>ripple\module\app\paths</Filter>
</ClInclude>
<ClCompile Include="..\..\src\ripple\module\app\paths\cursor\AdvanceNode.cpp">
<Filter>ripple\module\app\paths\cursor</Filter>
</ClCompile>
<ClCompile Include="..\..\src\ripple\module\app\paths\cursor\DeliverNodeForward.cpp">
<Filter>ripple\module\app\paths\cursor</Filter>
</ClCompile>
<ClCompile Include="..\..\src\ripple\module\app\paths\cursor\DeliverNodeReverse.cpp">
<Filter>ripple\module\app\paths\cursor</Filter>
</ClCompile>
<ClCompile Include="..\..\src\ripple\module\app\paths\cursor\ForwardLiquidity.cpp">
<Filter>ripple\module\app\paths\cursor</Filter>
</ClCompile>
<ClCompile Include="..\..\src\ripple\module\app\paths\cursor\ForwardLiquidityForAccount.cpp">
<Filter>ripple\module\app\paths\cursor</Filter>
</ClCompile>
<ClCompile Include="..\..\src\ripple\module\app\paths\cursor\Liquidity.cpp">
<Filter>ripple\module\app\paths\cursor</Filter>
</ClCompile>
<ClCompile Include="..\..\src\ripple\module\app\paths\cursor\NextIncrement.cpp">
<Filter>ripple\module\app\paths\cursor</Filter>
</ClCompile>
<ClInclude Include="..\..\src\ripple\module\app\paths\cursor\PathCursor.h">
<Filter>ripple\module\app\paths\cursor</Filter>
</ClInclude>
<ClCompile Include="..\..\src\ripple\module\app\paths\cursor\ReverseLiquidity.cpp">
<Filter>ripple\module\app\paths\cursor</Filter>
</ClCompile>
<ClCompile Include="..\..\src\ripple\module\app\paths\cursor\ReverseLiquidityForAccount.cpp">
<Filter>ripple\module\app\paths\cursor</Filter>
</ClCompile>
<ClCompile Include="..\..\src\ripple\module\app\paths\cursor\RippleLiquidity.cpp">
<Filter>ripple\module\app\paths\cursor</Filter>
</ClCompile>
<ClInclude Include="..\..\src\ripple\module\app\paths\cursor\RippleLiquidity.h">
<Filter>ripple\module\app\paths\cursor</Filter>
</ClInclude>
<ClInclude Include="..\..\src\ripple\module\app\peers\ClusterNodeStatus.h">
<Filter>ripple\module\app\peers</Filter>
</ClInclude>
Expand Down
54 changes: 27 additions & 27 deletions src/ripple/module/app/consensus/LedgerConsensus.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@ namespace ripple {

/**
Provides the implementation for LedgerConsensus.

Achieves consensus on the next ledger.
This object is created when the consensus process starts, and
is destroyed when the process is complete.

Nearly everything herein is invoked with the master lock.

Two things need consensus:
1. The set of transactions.
2. The close time for the ledger.
Expand All @@ -53,7 +53,7 @@ class LedgerConsensusImp

/**
The result of applying a transaction to a ledger.

@param clock The clock which will be used to measure time.
@param localtx A set of local transactions to apply.
@param prevLCLHash The hash of the Last Closed Ledger (LCL).
Expand Down Expand Up @@ -139,7 +139,7 @@ class LedgerConsensusImp

/**
This function is called, but its return value is always ignored.

@return 1.
*/
int startup ()
Expand All @@ -150,7 +150,7 @@ class LedgerConsensusImp
/**
Get the Json state of the consensus process.
Called by the consensus_info RPC.

@param full True if verbose response desired.
@return The Json state.
*/
Expand Down Expand Up @@ -290,7 +290,7 @@ class LedgerConsensusImp
Get a transaction tree, fetching it from the network if required and
requested. When the transaction acquire engine successfully acquires
a transaction set, it will call back.

@param hash hash of the requested transaction tree.
@param doAcquire true if we should get this from the network if we don't
already have it.
Expand Down Expand Up @@ -347,7 +347,7 @@ class LedgerConsensusImp

/**
We have a complete transaction set, typically acquired from the network

@param hash hash of the transaction set.
@param map the transaction set.
@param acquired true if we have acquired the transaction set.
Expand Down Expand Up @@ -438,7 +438,7 @@ class LedgerConsensusImp
If a transaction set is popular, we probably have it. If it's unpopular,
we probably don't need it (and the peer that initially made us
retrieve it has probably already changed its position).

@param hash hash of the transaction set.
@return true if we need to acquire it, else false.
*/
Expand Down Expand Up @@ -546,7 +546,7 @@ class LedgerConsensusImp

/**
Change our view of the last closed ledger

@param lclHash Hash of the last closed ledger.
*/
void handleLCL (uint256 const& lclHash)
Expand Down Expand Up @@ -707,7 +707,7 @@ class LedgerConsensusImp

/** We are establishing a consensus
Update our position only on the timer, and in this state.
If we have consensus, move to the finish state
If we have consensus, move to the finish state
*/
void stateEstablish ()
{
Expand Down Expand Up @@ -800,7 +800,7 @@ class LedgerConsensusImp
/**
A server has taken a new position, adjust our tracking
Called when a peer takes a new postion.

@param newPosition the new position
@return true if we should do delayed relay of this position.
*/
Expand Down Expand Up @@ -873,7 +873,7 @@ class LedgerConsensusImp

/**
A peer has informed us that it can give us a transaction set

@param peer The peer we can get it from.
@param hashSet The transaction set we can get.
@param status Says whether or not the peer has the transaction set
Expand Down Expand Up @@ -903,7 +903,7 @@ class LedgerConsensusImp

/**
A peer has sent us some nodes from a transaction set

@param peer The peer which has sent the nodes
@param setHash The transaction set
@param nodeIDs The nodes in the transaction set
Expand Down Expand Up @@ -945,7 +945,7 @@ class LedgerConsensusImp
}
private:
/** We have a new last closed ledger, process it. Final accept logic

@param set Our consensus set
*/
void accept (SHAMap::pointer set)
Expand Down Expand Up @@ -1189,7 +1189,7 @@ class LedgerConsensusImp

/**
Begin acquiring a transaction set

@param acquire The transaction set to acquire.
*/
void startAcquiring (TransactionAcquire::pointer acquire)
Expand Down Expand Up @@ -1244,7 +1244,7 @@ class LedgerConsensusImp
/**
Compare two proposed transaction sets and create disputed
transctions structures for any mismatches

@param m1 One transaction set
@param m2 The other transaction set
*/
Expand Down Expand Up @@ -1287,7 +1287,7 @@ class LedgerConsensusImp
/**
Add a disputed transaction (one that at least one node wants
in the consensus set and at least one node does not) to our tracking

@param txID The ID of the disputed transaction
@param tx The data of the disputed transaction
*/
Expand Down Expand Up @@ -1343,7 +1343,7 @@ class LedgerConsensusImp
/**
Adjust the votes on all disputed transactions based
on the set of peers taking this position

@param map A disputed position
@param peers peers which are taking the position map
*/
Expand Down Expand Up @@ -1385,7 +1385,7 @@ class LedgerConsensusImp

/** Let peers know that we a particular transactions set so they
can fetch it from us.

@param hash The ID of the transaction.
@param direct true if we have this transaction set locally, else a
directly connected peer has it.
Expand All @@ -1401,7 +1401,7 @@ class LedgerConsensusImp
}

/** Apply a set of transactions to a ledger

@param set The set of transactions to apply
@param applyLedger The ledger to which the transactions should
be applied.
Expand Down Expand Up @@ -1510,7 +1510,7 @@ class LedgerConsensusImp
}

/** Apply a transaction to a ledger

@param engine The transaction engine containing the ledger.
@param txn The transaction to be applied to ledger.
@param openLedger true if ledger is open
Expand Down Expand Up @@ -1584,17 +1584,17 @@ class LedgerConsensusImp

/**
Round the close time to the close time resolution.

@param closeTime The time to be rouned.
@return The rounded close time.
@return The rounded close time.
*/
std::uint32_t roundCloseTime (std::uint32_t closeTime)
{
return Ledger::roundCloseTime (closeTime, mCloseResolution);
}

/** Send a node status change message to our directly connected peers

@param event The event which caused the status change. This is
typically neACCEPTED_LEDGER or neCLOSING_LEDGER.
@param ledger The ledger associated with the event.
Expand Down Expand Up @@ -1638,7 +1638,7 @@ class LedgerConsensusImp

/** Take an initial position on what we think the consensus should be
based on the transactions that made it into our open ledger

@param initialLedger The ledger that contains our initial position.
*/
void takeInitialPosition (Ledger& initialLedger)
Expand Down Expand Up @@ -1710,7 +1710,7 @@ class LedgerConsensusImp
/**
For a given number of participants and required percent
for consensus, how many participants must agree?

@param size number of validators
@param percent desired percent for consensus
@return number of participates which must agree
Expand Down
6 changes: 4 additions & 2 deletions src/ripple/module/app/ledger/AcceptedLedger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,12 @@ AcceptedLedger::AcceptedLedger (Ledger::ref ledger) : mLedger (ledger)
{
SHAMap& txSet = *ledger->peekTransactionMap ();

for (SHAMapItem::pointer item = txSet.peekFirstItem (); !!item; item = txSet.peekNextItem (item->getTag ()))
for (SHAMapItem::pointer item = txSet.peekFirstItem (); item;
item = txSet.peekNextItem (item->getTag ()))
{
SerializerIterator sit (item->peekSerializer ());
insert (std::make_shared<AcceptedLedgerTx> (ledger->getLedgerSeq (), std::ref (sit)));
insert (std::make_shared<AcceptedLedgerTx> (
ledger->getLedgerSeq (), sit));
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/ripple/module/app/ledger/AcceptedLedgerTx.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ class AcceptedLedgerTx

bool isApplied () const
{
return !!mMeta;
return bool(mMeta);
}
int getIndex () const
{
Expand Down
4 changes: 2 additions & 2 deletions src/ripple/module/app/ledger/Ledger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -765,7 +765,7 @@ bool Ledger::saveValidatedLedger (bool current)
{
auto sl (getApp().getLedgerDB ()->lock ());

// TODO(tom): ARG!!
// TODO(tom): ARG!
getApp().getLedgerDB ()->getDB ()->executeSQL (boost::str (addLedger %
to_string (getHash ()) % mLedgerSeq % to_string (mParentHash) %
beast::lexicalCastThrow <std::string> (mTotCoins) % mCloseTime %
Expand Down Expand Up @@ -1187,7 +1187,7 @@ Json::Value Ledger::getJson (int options)
Json::Value& txns = (ledger[jss::transactions] = Json::arrayValue);
SHAMapTreeNode::TNType type;

for (auto item = mTransactionMap->peekFirstItem (type); !!item;
for (auto item = mTransactionMap->peekFirstItem (type); item;
item = mTransactionMap->peekNextItem (item->getTag (), type))
{
if (bFull || bExpand)
Expand Down
Loading