mirror of
https://github.com/Xahau/xahaud.git
synced 2025-12-06 17:27:52 +00:00
Add AgedHistory.h
This commit is contained in:
@@ -1635,6 +1635,7 @@
|
|||||||
<ClInclude Include="..\..\src\ripple\validators\api\Source.h" />
|
<ClInclude Include="..\..\src\ripple\validators\api\Source.h" />
|
||||||
<ClInclude Include="..\..\src\ripple\validators\api\Types.h" />
|
<ClInclude Include="..\..\src\ripple\validators\api\Types.h" />
|
||||||
<ClInclude Include="..\..\src\ripple\validators\api\Manager.h" />
|
<ClInclude Include="..\..\src\ripple\validators\api\Manager.h" />
|
||||||
|
<ClInclude Include="..\..\src\ripple\validators\impl\AgedHistory.h" />
|
||||||
<ClInclude Include="..\..\src\ripple\validators\impl\CancelCallbacks.h" />
|
<ClInclude Include="..\..\src\ripple\validators\impl\CancelCallbacks.h" />
|
||||||
<ClInclude Include="..\..\src\ripple\validators\impl\ChosenList.h" />
|
<ClInclude Include="..\..\src\ripple\validators\impl\ChosenList.h" />
|
||||||
<ClInclude Include="..\..\src\ripple\validators\impl\Logic.h" />
|
<ClInclude Include="..\..\src\ripple\validators\impl\Logic.h" />
|
||||||
|
|||||||
@@ -2115,6 +2115,9 @@
|
|||||||
<ClInclude Include="..\..\src\ripple_basics\containers\BlackList.h">
|
<ClInclude Include="..\..\src\ripple_basics\containers\BlackList.h">
|
||||||
<Filter>[2] Old Ripple\ripple_basics\containers</Filter>
|
<Filter>[2] Old Ripple\ripple_basics\containers</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\..\src\ripple\validators\impl\AgedHistory.h">
|
||||||
|
<Filter>[1] Ripple\validators\impl</Filter>
|
||||||
|
</ClInclude>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<CustomBuild Include="..\..\src\ripple_data\protocol\ripple.proto">
|
<CustomBuild Include="..\..\src\ripple_data\protocol\ripple.proto">
|
||||||
|
|||||||
77
src/ripple/validators/impl/AgedHistory.h
Normal file
77
src/ripple/validators/impl/AgedHistory.h
Normal file
@@ -0,0 +1,77 @@
|
|||||||
|
//------------------------------------------------------------------------------
|
||||||
|
/*
|
||||||
|
This file is part of rippled: https://github.com/ripple/rippled
|
||||||
|
Copyright (c) 2012, 2013 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_VALIDATORS_AGEDHISTORY_H_INCLUDED
|
||||||
|
#define RIPPLE_VALIDATORS_AGEDHISTORY_H_INCLUDED
|
||||||
|
|
||||||
|
namespace ripple {
|
||||||
|
namespace Validators {
|
||||||
|
|
||||||
|
// Simple container swapping template
|
||||||
|
template <class Container>
|
||||||
|
class AgedHistory
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
typedef Container container_type;
|
||||||
|
|
||||||
|
AgedHistory()
|
||||||
|
: m_p1 (&m_c1)
|
||||||
|
, m_p2 (&m_c2)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
AgedHistory (AgedHistory const& other)
|
||||||
|
: m_c1 (other.front())
|
||||||
|
, m_c2 (other.back())
|
||||||
|
, m_p1 (&m_c1)
|
||||||
|
, m_p2 (&m_c2)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
AgedHistory& operator= (AgedHistory const& other)
|
||||||
|
{
|
||||||
|
m_c1 = other.front();
|
||||||
|
m_c2 = other.back();
|
||||||
|
m_p1 = &m_c1;
|
||||||
|
m_p2 = &m_c2;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
void swap () { std::swap (m_p1, m_p2); }
|
||||||
|
|
||||||
|
Container* operator-> () { return m_p1; }
|
||||||
|
Container const* operator-> () const { return m_p1; }
|
||||||
|
|
||||||
|
Container& front() { return *m_p1; }
|
||||||
|
Container const& front() const { return *m_p1; }
|
||||||
|
Container& back() { return *m_p2; }
|
||||||
|
Container const& back() const { return *m_p2; }
|
||||||
|
|
||||||
|
private:
|
||||||
|
Container m_c1;
|
||||||
|
Container m_c2;
|
||||||
|
Container* m_p1;
|
||||||
|
Container* m_p2;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -21,6 +21,8 @@
|
|||||||
#ifndef RIPPLE_VALIDATORS_LOGIC_H_INCLUDED
|
#ifndef RIPPLE_VALIDATORS_LOGIC_H_INCLUDED
|
||||||
#define RIPPLE_VALIDATORS_LOGIC_H_INCLUDED
|
#define RIPPLE_VALIDATORS_LOGIC_H_INCLUDED
|
||||||
|
|
||||||
|
#include "AgedHistory.h"
|
||||||
|
|
||||||
namespace ripple {
|
namespace ripple {
|
||||||
namespace Validators {
|
namespace Validators {
|
||||||
|
|
||||||
@@ -46,53 +48,6 @@ enum
|
|||||||
maxSizeBeforeSwap = 100
|
maxSizeBeforeSwap = 100
|
||||||
};
|
};
|
||||||
|
|
||||||
// Simple container swapping template
|
|
||||||
template <class Container>
|
|
||||||
class AgedHistory
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
typedef Container container_type;
|
|
||||||
|
|
||||||
AgedHistory()
|
|
||||||
: m_p1 (&m_c1)
|
|
||||||
, m_p2 (&m_c2)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
AgedHistory (AgedHistory const& other)
|
|
||||||
: m_c1 (other.front())
|
|
||||||
, m_c2 (other.back())
|
|
||||||
, m_p1 (&m_c1)
|
|
||||||
, m_p2 (&m_c2)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
AgedHistory& operator= (AgedHistory const& other)
|
|
||||||
{
|
|
||||||
m_c1 = other.front();
|
|
||||||
m_c2 = other.back();
|
|
||||||
m_p1 = &m_c1;
|
|
||||||
m_p2 = &m_c2;
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
void swap () { std::swap (m_p1, m_p2); }
|
|
||||||
|
|
||||||
Container* operator-> () { return m_p1; }
|
|
||||||
Container const* operator-> () const { return m_p1; }
|
|
||||||
|
|
||||||
Container& front() { return *m_p1; }
|
|
||||||
Container const& front() const { return *m_p1; }
|
|
||||||
Container& back() { return *m_p2; }
|
|
||||||
Container const& back() const { return *m_p2; }
|
|
||||||
|
|
||||||
private:
|
|
||||||
Container m_c1;
|
|
||||||
Container m_c2;
|
|
||||||
Container* m_p1;
|
|
||||||
Container* m_p2;
|
|
||||||
};
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
struct Ledger
|
struct Ledger
|
||||||
|
|||||||
Reference in New Issue
Block a user