mirror of
https://github.com/Xahau/xahaud.git
synced 2025-12-06 17:27:52 +00:00
Add jtx support for trust line quality (RIPD-1094)
This commit is contained in:
committed by
Miguel Portilla
parent
a698104c55
commit
0952ebfc1d
@@ -3603,6 +3603,10 @@
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='debug|x64'">True</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='release|x64'">True</ExcludedFromBuild>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\ripple\test\jtx\impl\quality.cpp">
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='debug|x64'">True</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='release|x64'">True</ExcludedFromBuild>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\ripple\test\jtx\impl\rate.cpp">
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='debug|x64'">True</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='release|x64'">True</ExcludedFromBuild>
|
||||
@@ -3663,6 +3667,8 @@
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\ripple\test\jtx\prop.h">
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\ripple\test\jtx\quality.h">
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\ripple\test\jtx\rate.h">
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\ripple\test\jtx\regkey.h">
|
||||
|
||||
@@ -4065,6 +4065,9 @@
|
||||
<ClCompile Include="..\..\src\ripple\test\jtx\impl\pay.cpp">
|
||||
<Filter>ripple\test\jtx\impl</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\ripple\test\jtx\impl\quality.cpp">
|
||||
<Filter>ripple\test\jtx\impl</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\ripple\test\jtx\impl\rate.cpp">
|
||||
<Filter>ripple\test\jtx\impl</Filter>
|
||||
</ClCompile>
|
||||
@@ -4125,6 +4128,9 @@
|
||||
<ClInclude Include="..\..\src\ripple\test\jtx\prop.h">
|
||||
<Filter>ripple\test\jtx</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\ripple\test\jtx\quality.h">
|
||||
<Filter>ripple\test\jtx</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\ripple\test\jtx\rate.h">
|
||||
<Filter>ripple\test\jtx</Filter>
|
||||
</ClInclude>
|
||||
|
||||
@@ -41,6 +41,7 @@
|
||||
#include <ripple/test/jtx/paths.h>
|
||||
#include <ripple/test/jtx/pay.h>
|
||||
#include <ripple/test/jtx/prop.h>
|
||||
#include <ripple/test/jtx/quality.h>
|
||||
#include <ripple/test/jtx/rate.h>
|
||||
#include <ripple/test/jtx/regkey.h>
|
||||
#include <ripple/test/jtx/require.h>
|
||||
|
||||
73
src/ripple/test/jtx/impl/quality.cpp
Normal file
73
src/ripple/test/jtx/impl/quality.cpp
Normal file
@@ -0,0 +1,73 @@
|
||||
//------------------------------------------------------------------------------
|
||||
/*
|
||||
This file is part of rippled: https://github.com/ripple/rippled
|
||||
Copyright (c) 2016 Ripple Labs Inc.
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
copyright notice and this permission notice appear in all copies.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
//==============================================================================
|
||||
|
||||
#include <BeastConfig.h>
|
||||
#include <ripple/test/jtx/quality.h>
|
||||
#include <ripple/protocol/SField.h>
|
||||
#include <ripple/protocol/Quality.h>
|
||||
|
||||
namespace ripple {
|
||||
namespace test {
|
||||
namespace jtx {
|
||||
|
||||
qualityInPercent::qualityInPercent (double percent)
|
||||
: qIn_ (static_cast<std::uint32_t>((percent / 100) * QUALITY_ONE))
|
||||
{
|
||||
assert (percent <= 400 && percent >= 0);
|
||||
}
|
||||
|
||||
qualityOutPercent::qualityOutPercent (double percent)
|
||||
: qOut_ (static_cast<std::uint32_t>((percent / 100) * QUALITY_ONE))
|
||||
{
|
||||
assert (percent <= 400 && percent >= 0);
|
||||
}
|
||||
|
||||
static void
|
||||
insertQualityIntoJtx (SField const& field, std::uint32_t value, JTx& jt)
|
||||
{
|
||||
jt.jv[field.jsonName] = value;
|
||||
}
|
||||
|
||||
void
|
||||
qualityIn::operator()(Env&, JTx& jt) const
|
||||
{
|
||||
insertQualityIntoJtx (sfQualityIn, qIn_, jt);
|
||||
}
|
||||
|
||||
void
|
||||
qualityInPercent::operator()(Env&, JTx& jt) const
|
||||
{
|
||||
insertQualityIntoJtx (sfQualityIn, qIn_, jt);
|
||||
}
|
||||
|
||||
void
|
||||
qualityOut::operator()(Env&, JTx& jt) const
|
||||
{
|
||||
insertQualityIntoJtx (sfQualityOut, qOut_, jt);
|
||||
}
|
||||
|
||||
void
|
||||
qualityOutPercent::operator()(Env&, JTx& jt) const
|
||||
{
|
||||
insertQualityIntoJtx (sfQualityOut, qOut_, jt);
|
||||
}
|
||||
|
||||
} // jtx
|
||||
} // test
|
||||
} // ripple
|
||||
91
src/ripple/test/jtx/quality.h
Normal file
91
src/ripple/test/jtx/quality.h
Normal file
@@ -0,0 +1,91 @@
|
||||
//------------------------------------------------------------------------------
|
||||
/*
|
||||
This file is part of rippled: https://github.com/ripple/rippled
|
||||
Copyright (c) 2016 Ripple Labs Inc.
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
copyright notice and this permission notice appear in all copies.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
//==============================================================================
|
||||
|
||||
#ifndef RIPPLE_TEST_JTX_QUALITY_H_INCLUDED
|
||||
#define RIPPLE_TEST_JTX_QUALITY_H_INCLUDED
|
||||
|
||||
#include <ripple/test/jtx/Env.h>
|
||||
|
||||
namespace ripple {
|
||||
namespace test {
|
||||
namespace jtx {
|
||||
|
||||
/** Sets the literal QualityIn on a trust JTx. */
|
||||
class qualityIn
|
||||
{
|
||||
private:
|
||||
std::uint32_t qIn_;
|
||||
|
||||
public:
|
||||
explicit qualityIn (std::uint32_t qIn)
|
||||
: qIn_ (qIn)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
operator()(Env&, JTx& jtx) const;
|
||||
};
|
||||
|
||||
/** Sets the QualityIn on a trust JTx as a percentage. */
|
||||
class qualityInPercent
|
||||
{
|
||||
private:
|
||||
std::uint32_t qIn_;
|
||||
|
||||
public:
|
||||
explicit qualityInPercent (double percent);
|
||||
|
||||
void
|
||||
operator()(Env&, JTx& jtx) const;
|
||||
};
|
||||
|
||||
/** Sets the literal QualityOut on a trust JTx. */
|
||||
class qualityOut
|
||||
{
|
||||
private:
|
||||
std::uint32_t qOut_;
|
||||
|
||||
public:
|
||||
explicit qualityOut (std::uint32_t qOut)
|
||||
: qOut_ (qOut)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
operator()(Env&, JTx& jtx) const;
|
||||
};
|
||||
|
||||
/** Sets the QualityOut on a trust JTx as a percentage. */
|
||||
class qualityOutPercent
|
||||
{
|
||||
private:
|
||||
std::uint32_t qOut_;
|
||||
|
||||
public:
|
||||
explicit qualityOutPercent (double percent);
|
||||
|
||||
void
|
||||
operator()(Env&, JTx& jtx) const;
|
||||
};
|
||||
|
||||
} // jtx
|
||||
} // test
|
||||
} // ripple
|
||||
|
||||
#endif
|
||||
@@ -34,6 +34,7 @@
|
||||
#include <ripple/test/jtx/impl/owners.cpp>
|
||||
#include <ripple/test/jtx/impl/paths.cpp>
|
||||
#include <ripple/test/jtx/impl/pay.cpp>
|
||||
#include <ripple/test/jtx/impl/quality.cpp>
|
||||
#include <ripple/test/jtx/impl/rate.cpp>
|
||||
#include <ripple/test/jtx/impl/regkey.cpp>
|
||||
#include <ripple/test/jtx/impl/sendmax.cpp>
|
||||
|
||||
Reference in New Issue
Block a user