mirror of
https://github.com/Xahau/xahaud.git
synced 2025-11-30 23:45:48 +00:00
Refactor RippleCalc.cpp:
* Add comments * Restrict code to 80 colums * Remove boost::format * Remove BOOST_FOREACH * Make members private * Add ripple_unordered_set to UnorderedContainers.h * Replace boost::unordered_set with ripple::unordered_set
This commit is contained in:
@@ -29,7 +29,7 @@
|
||||
#include "../../beast/beast/chrono/chrono_io.h"
|
||||
#include "../../beast/beast/Insight.h"
|
||||
#include "../../beast/beast/container/hardened_hash.h"
|
||||
#include "UnorderedMap.h"
|
||||
#include "UnorderedContainers.h"
|
||||
|
||||
namespace ripple {
|
||||
|
||||
|
||||
@@ -17,12 +17,13 @@
|
||||
*/
|
||||
//==============================================================================
|
||||
|
||||
#ifndef RIPPLE_UNORDERED_MAP_H
|
||||
#define RIPPLE_UNORDERED_MAP_H
|
||||
#ifndef RIPPLE_UNORDERED_CONTAINERS_H
|
||||
#define RIPPLE_UNORDERED_CONTAINERS_H
|
||||
|
||||
#include "../../beast/beast/container/hash_append.h"
|
||||
|
||||
#include <unordered_map>
|
||||
#include <unordered_set>
|
||||
|
||||
namespace ripple
|
||||
{
|
||||
@@ -32,6 +33,11 @@ template <class Key, class Value, class Hash = beast::uhash<>,
|
||||
class Allocator = std::allocator<std::pair<Key const, Value>>>
|
||||
using unordered_map = std::unordered_map <Key, Value, Hash, Pred, Allocator>;
|
||||
|
||||
template <class Value, class Hash = beast::uhash<>,
|
||||
class Pred = std::equal_to<Value>,
|
||||
class Allocator = std::allocator<Value>>
|
||||
using unordered_set = std::unordered_set <Value, Hash, Pred, Allocator>;
|
||||
|
||||
} // ripple
|
||||
|
||||
#endif
|
||||
@@ -20,7 +20,7 @@
|
||||
#ifndef RIPPLE_RESOURCE_LOGIC_H_INCLUDED
|
||||
#define RIPPLE_RESOURCE_LOGIC_H_INCLUDED
|
||||
|
||||
#include "../../common/UnorderedMap.h"
|
||||
#include "../../common/UnorderedContainers.h"
|
||||
|
||||
#include "../../beast/beast/chrono/abstract_clock.h"
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
#ifndef RIPPLE_SITEFILES_SECTION_H_INCLUDED
|
||||
#define RIPPLE_SITEFILES_SECTION_H_INCLUDED
|
||||
|
||||
#include "../../common/UnorderedMap.h"
|
||||
#include "../../common/UnorderedContainers.h"
|
||||
#include <vector>
|
||||
|
||||
namespace ripple {
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
#define RIPPLE_SITEFILES_SITEFILE_H_INCLUDED
|
||||
|
||||
#include "Section.h"
|
||||
#include "../../common/UnorderedMap.h"
|
||||
#include "../../common/UnorderedContainers.h"
|
||||
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
#ifndef RIPPLE_SITEFILES_LOGIC_H_INCLUDED
|
||||
#define RIPPLE_SITEFILES_LOGIC_H_INCLUDED
|
||||
|
||||
#include "../../common/UnorderedMap.h"
|
||||
#include "../../common/UnorderedContainers.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
*/
|
||||
//==============================================================================
|
||||
|
||||
#include "../../common/UnorderedMap.h"
|
||||
#include "../../common/UnorderedContainers.h"
|
||||
|
||||
#include "../../../beast/beast/unit_test/suite.h"
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
*/
|
||||
//==============================================================================
|
||||
|
||||
#include "../../common/UnorderedMap.h"
|
||||
#include "../../common/UnorderedContainers.h"
|
||||
|
||||
#include "../../../beast/beast/unit_test/suite.h"
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
#ifndef RIPPLE_VALIDATORS_CHOSENLIST_H_INCLUDED
|
||||
#define RIPPLE_VALIDATORS_CHOSENLIST_H_INCLUDED
|
||||
|
||||
#include "../../common/UnorderedMap.h"
|
||||
#include "../../common/UnorderedContainers.h"
|
||||
|
||||
namespace ripple {
|
||||
namespace Validators {
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
#ifndef RIPPLE_VALIDATORS_TUNING_H_INCLUDED
|
||||
#define RIPPLE_VALIDATORS_TUNING_H_INCLUDED
|
||||
|
||||
#include "../../common/UnorderedMap.h"
|
||||
#include "../../common/UnorderedContainers.h"
|
||||
|
||||
#include <boost/version.hpp>
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -27,26 +27,46 @@ namespace ripple {
|
||||
The quality is a synonym for price. Specifically, the amount of
|
||||
input required to produce a given output along a specified path.
|
||||
*/
|
||||
// VFALCO TODO What's the difference between a RippleState versus PathState?
|
||||
|
||||
// TODO(vfalco) What's the difference between a RippleState versus PathState?
|
||||
//
|
||||
class RippleCalc
|
||||
{
|
||||
public:
|
||||
// First time working in reverse a funding source was mentioned. Source may only be used there.
|
||||
curIssuerNode mumSource; // Map of currency, issuer to node index.
|
||||
private:
|
||||
// First time working in reverse a funding source was mentioned. Source may
|
||||
// only be used there.
|
||||
//
|
||||
// Map of currency, issuer to node index.
|
||||
curIssuerNode mumSource;
|
||||
|
||||
// If the transaction fails to meet some constraint, still need to delete unfunded offers.
|
||||
boost::unordered_set<uint256> musUnfundedFound; // Offers that were found unfunded.
|
||||
// If the transaction fails to meet some constraint, still need to delete
|
||||
// unfunded offers.
|
||||
//
|
||||
// Offers that were found unfunded.
|
||||
unordered_set<uint256> mUnfundedOffers;
|
||||
|
||||
void pathNext (
|
||||
PathState::ref psrCur, const bool bMultiQuality,
|
||||
const LedgerEntrySet& lesCheckpoint, LedgerEntrySet& lesCurrent);
|
||||
|
||||
TER calcNode (
|
||||
const unsigned int uNode, PathState& psCur, const bool bMultiQuality);
|
||||
TER calcNodeRev (
|
||||
const unsigned int uNode, PathState& psCur, const bool bMultiQuality);
|
||||
TER calcNodeFwd (
|
||||
const unsigned int uNode, PathState& psCur, const bool bMultiQuality);
|
||||
TER calcNodeOfferRev (
|
||||
const unsigned int uNode, PathState& psCur, const bool bMultiQuality);
|
||||
TER calcNodeOfferFwd (
|
||||
const unsigned int uNode, PathState& psCur, const bool bMultiQuality);
|
||||
TER calcNodeAccountRev (
|
||||
const unsigned int uNode, PathState& psCur, const bool bMultiQuality);
|
||||
TER calcNodeAccountFwd (
|
||||
const unsigned int uNode, PathState& psCur, const bool bMultiQuality);
|
||||
TER calcNodeAdvance (
|
||||
const unsigned int uNode, PathState& psCur, const bool bMultiQuality,
|
||||
const bool bReverse);
|
||||
|
||||
void pathNext (PathState::ref psrCur, const bool bMultiQuality, const LedgerEntrySet& lesCheckpoint, LedgerEntrySet& lesCurrent);
|
||||
TER calcNode (const unsigned int uNode, PathState& psCur, const bool bMultiQuality);
|
||||
TER calcNodeRev (const unsigned int uNode, PathState& psCur, const bool bMultiQuality);
|
||||
TER calcNodeFwd (const unsigned int uNode, PathState& psCur, const bool bMultiQuality);
|
||||
TER calcNodeOfferRev (const unsigned int uNode, PathState& psCur, const bool bMultiQuality);
|
||||
TER calcNodeOfferFwd (const unsigned int uNode, PathState& psCur, const bool bMultiQuality);
|
||||
TER calcNodeAccountRev (const unsigned int uNode, PathState& psCur, const bool bMultiQuality);
|
||||
TER calcNodeAccountFwd (const unsigned int uNode, PathState& psCur, const bool bMultiQuality);
|
||||
TER calcNodeAdvance (const unsigned int uNode, PathState& psCur, const bool bMultiQuality, const bool bReverse);
|
||||
TER calcNodeDeliverRev (
|
||||
const unsigned int uNode,
|
||||
PathState& psCur,
|
||||
@@ -64,17 +84,17 @@ public:
|
||||
STAmount& saInAct,
|
||||
STAmount& saInFees);
|
||||
|
||||
void calcNodeRipple (const std::uint32_t uQualityIn, const std::uint32_t uQualityOut,
|
||||
void calcNodeRipple (
|
||||
const std::uint32_t uQualityIn, const std::uint32_t uQualityOut,
|
||||
const STAmount& saPrvReq, const STAmount& saCurReq,
|
||||
STAmount& saPrvAct, STAmount& saCurAct,
|
||||
std::uint64_t& uRateMax);
|
||||
STAmount& saPrvAct, STAmount& saCurAct, std::uint64_t& uRateMax);
|
||||
|
||||
RippleCalc (LedgerEntrySet& lesNodes, const bool bOpenLedger)
|
||||
: lesActive (lesNodes), mOpenLedger (bOpenLedger)
|
||||
RippleCalc (LedgerEntrySet& activeLedger, const bool bOpenLedger)
|
||||
: mActiveLedger (activeLedger), mOpenLedger (bOpenLedger)
|
||||
{
|
||||
;
|
||||
}
|
||||
|
||||
public:
|
||||
static TER rippleCalc (
|
||||
LedgerEntrySet& lesActive,
|
||||
STAmount& saMaxAmountAct,
|
||||
@@ -88,14 +108,18 @@ public:
|
||||
const bool bPartialPayment,
|
||||
const bool bLimitQuality,
|
||||
const bool bNoRippleDirect,
|
||||
const bool bStandAlone, // --> True, not to affect accounts.
|
||||
const bool bOpenLedger = true // --> What kind of errors to return.
|
||||
// --> True, not to affect accounts.
|
||||
const bool bStandAlone,
|
||||
// --> What kind of errors to return.
|
||||
const bool bOpenLedger = true
|
||||
);
|
||||
|
||||
static void setCanonical (STPathSet& spsDst, const std::vector<PathState::pointer>& vpsExpanded, bool bKeepDefault);
|
||||
static void setCanonical (
|
||||
STPathSet& spsDst, const std::vector<PathState::pointer>& vpsExpanded,
|
||||
bool bKeepDefault);
|
||||
|
||||
protected:
|
||||
LedgerEntrySet& lesActive;
|
||||
private:
|
||||
LedgerEntrySet& mActiveLedger;
|
||||
bool mOpenLedger;
|
||||
};
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
#ifndef RIPPLE_SYNC_UNORDERED_MAP_H
|
||||
#define RIPPLE_SYNC_UNORDERED_MAP_H
|
||||
|
||||
#include "../../ripple/common/UnorderedMap.h"
|
||||
#include "../../ripple/common/UnorderedContainers.h"
|
||||
|
||||
namespace ripple {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user