mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 17:27:55 +00:00
Tidy up UNL module:
* Renamed module to unl * Renamed classes and members * Removed cyclic dependency in Horizon
This commit is contained in:
committed by
Nik Bougalis
parent
5d2d88209f
commit
2bfae2f0ac
@@ -1,41 +0,0 @@
|
||||
//------------------------------------------------------------------------------
|
||||
/*
|
||||
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_CONNECTION_H_INCLUDED
|
||||
#define RIPPLE_VALIDATORS_CONNECTION_H_INCLUDED
|
||||
|
||||
#include <ripple/protocol/STValidation.h>
|
||||
|
||||
namespace ripple {
|
||||
namespace Validators {
|
||||
|
||||
/** Represents validator concerns on a protocol connection. */
|
||||
class Connection
|
||||
{
|
||||
public:
|
||||
virtual ~Connection() = default;
|
||||
|
||||
/** Called when a signed validation is received on the connection. */
|
||||
virtual void onValidation (STValidation const& v) = 0;
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -1,62 +0,0 @@
|
||||
# Validators
|
||||
|
||||
The Validators module has these responsibilities:
|
||||
|
||||
- Provide an administrative interface for maintaining the list _Source_
|
||||
locations.
|
||||
- Report performance statistics on _Source_ locations
|
||||
- Report performance statistics on _validators_ provided by _Source_ locations.
|
||||
- Choose a suitable random subset of observed _Validators_ to become the
|
||||
_Chosen Validators_ set.
|
||||
- Update the _Chosen Validators_ set as needed to meet performance requirements.
|
||||
|
||||
## Description
|
||||
|
||||
The consensus process used by the Ripple payment protocol requires that ledger
|
||||
hashes be signed by _Validators_, producing a _Validation_. The integrity of
|
||||
the process is mathematically assured when each node chooses a random subset
|
||||
of _Validators_ to trust, where each _Validator_ is a public verifiable entity
|
||||
that is independent. Or more specifically, no entity should be in control of
|
||||
any significant number of _validators_ chosen by each node.
|
||||
|
||||
The list of _Validators_ a node chooses to trust is called the _Chosen
|
||||
Validators_. The **Validators** module implements business logic to automate the
|
||||
selection of _Chosen Validators_ by allowing the administrator to provide one
|
||||
or more trusted _Sources_, from which _Validators_ are learned. Performance
|
||||
statistics are tracked for these _Validators_, and the module chooses a
|
||||
suitable subset from which to form the _Chosen Validators_ list.
|
||||
|
||||
The module looks for these criteria to determine suitability:
|
||||
|
||||
- Different validators are not controlled by the same entity.
|
||||
- Each validator participates in a majority of ledgers.
|
||||
- A validator does not sign ledgers that fail the consensus process.
|
||||
|
||||
## Terms
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<td>Chosen Validators</td>
|
||||
<td>A set of validators chosen by the Validators module. This is the new term
|
||||
for what was formerly known as the Unique Node List.
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Source</td>
|
||||
<td>A trusted source of validator descriptors. Examples: the rippled
|
||||
configuration file, a local text file, or a trusted URL such
|
||||
as https://ripple.com/validators.txt.
|
||||
</td></tr>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Validation</td>
|
||||
<td>A closed ledger hash signed by a validator.
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Validator</td>
|
||||
<td>A publicly verifiable entity which signs ledger hashes with its private
|
||||
key, and makes its public key available through out of band means.
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
@@ -1,27 +0,0 @@
|
||||
//------------------------------------------------------------------------------
|
||||
/*
|
||||
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.
|
||||
*/
|
||||
//==============================================================================
|
||||
|
||||
#include <BeastConfig.h>
|
||||
#include <ripple/validators/impl/ConnectionImp.h>
|
||||
|
||||
namespace ripple {
|
||||
namespace Validators {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,207 +0,0 @@
|
||||
//------------------------------------------------------------------------------
|
||||
/*
|
||||
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_CONNECTIONIMP_H_INCLUDED
|
||||
#define RIPPLE_VALIDATORS_CONNECTIONIMP_H_INCLUDED
|
||||
|
||||
#include <ripple/basics/hardened_hash.h>
|
||||
#include <ripple/protocol/RippleAddress.h>
|
||||
#include <ripple/validators/Connection.h>
|
||||
#include <ripple/validators/impl/Logic.h>
|
||||
#include <beast/utility/WrappedSink.h>
|
||||
#include <boost/container/flat_map.hpp>
|
||||
#include <boost/container/flat_set.hpp>
|
||||
#include <boost/optional.hpp>
|
||||
#include <mutex>
|
||||
#include <sstream>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include <map>
|
||||
|
||||
namespace ripple {
|
||||
namespace Validators {
|
||||
|
||||
class ConnectionImp
|
||||
: public Connection
|
||||
{
|
||||
private:
|
||||
// Metadata on a validation source
|
||||
struct Source
|
||||
{
|
||||
// New sources are just at the threshold
|
||||
double score = 0.8;
|
||||
|
||||
// returns `true` if the score is high
|
||||
// enough to count as available
|
||||
bool
|
||||
available() const
|
||||
{
|
||||
return score >= 0.8;
|
||||
}
|
||||
|
||||
// returns `true` if the score is so low we
|
||||
// have no expectation of seeing the validator again
|
||||
bool
|
||||
gone() const
|
||||
{
|
||||
return score <= 0.2;
|
||||
}
|
||||
|
||||
// returns `true` if became unavailable
|
||||
bool
|
||||
onHit()
|
||||
{
|
||||
bool const prev = available();
|
||||
score = 0.90 * score + 0.10;
|
||||
if (! prev && available())
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
// returns `true` if became available
|
||||
bool
|
||||
onMiss()
|
||||
{
|
||||
bool const prev = available();
|
||||
score = 0.90 * score;
|
||||
if (prev && ! available())
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
using Item = std::pair<LedgerHash, RippleAddress>;
|
||||
|
||||
Logic& logic_;
|
||||
beast::WrappedSink sink_;
|
||||
beast::Journal journal_;
|
||||
std::mutex mutex_;
|
||||
boost::optional<LedgerHash> ledger_;
|
||||
boost::container::flat_set<Item> items_;
|
||||
boost::container::flat_map<RippleAddress, Source> sources_;
|
||||
boost::container::flat_set<RippleAddress> good_;
|
||||
|
||||
static
|
||||
std::string
|
||||
makePrefix (int id)
|
||||
{
|
||||
std::stringstream ss;
|
||||
ss << "[" << std::setfill('0') << std::setw(3) << id << "] ";
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
public:
|
||||
template <class Clock>
|
||||
ConnectionImp (int id, Logic& logic, Clock& clock)
|
||||
: logic_ (logic)
|
||||
, sink_ (logic.journal(), makePrefix(id))
|
||||
, journal_ (sink_)
|
||||
{
|
||||
logic_.add(*this);
|
||||
}
|
||||
|
||||
~ConnectionImp()
|
||||
{
|
||||
logic_.remove(*this);
|
||||
}
|
||||
|
||||
void
|
||||
onValidation (STValidation const& v) override
|
||||
{
|
||||
auto const key = v.getSignerPublic();
|
||||
auto const ledger = v.getLedgerHash();
|
||||
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(mutex_);
|
||||
if (! items_.emplace(ledger, key).second)
|
||||
return;
|
||||
if (journal_.debug) journal_.debug <<
|
||||
"onValidation: " << ledger;
|
||||
#if 0
|
||||
auto const result = sources_.emplace(
|
||||
std::piecewise_construct, std::make_tuple(key),
|
||||
std::make_tuple());
|
||||
#else
|
||||
// Work-around for boost::container
|
||||
auto const result = sources_.emplace(key, Source{});
|
||||
#endif
|
||||
if (result.second)
|
||||
good_.insert(key);
|
||||
// register a hit for slightly late validations
|
||||
if (ledger_ && ledger == ledger_)
|
||||
if (result.first->second.onHit())
|
||||
good_.insert(key);
|
||||
}
|
||||
|
||||
// This can call onLedger, do it last
|
||||
logic_.onValidation(v);
|
||||
}
|
||||
|
||||
// Called when a supermajority of
|
||||
// validations are received for the next ledger.
|
||||
void
|
||||
onLedger (LedgerHash const& ledger)
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(mutex_);
|
||||
if (journal_.debug) journal_.debug <<
|
||||
"onLedger: " << ledger;
|
||||
assert(ledger != ledger_);
|
||||
ledger_ = ledger;
|
||||
auto item = items_.lower_bound(
|
||||
std::make_pair(ledger, RippleAddress()));
|
||||
auto source = sources_.begin();
|
||||
while (item != items_.end() &&
|
||||
source != sources_.end() &&
|
||||
item->first == ledger)
|
||||
{
|
||||
if (item->second < source->first)
|
||||
{
|
||||
++item;
|
||||
}
|
||||
else if (item->second == source->first)
|
||||
{
|
||||
if (source->second.onHit())
|
||||
good_.insert(source->first);
|
||||
++item;
|
||||
++source;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (source->second.onMiss())
|
||||
good_.erase(source->first);
|
||||
++source;
|
||||
}
|
||||
}
|
||||
while (source != sources_.end())
|
||||
{
|
||||
if (source->second.onMiss())
|
||||
good_.erase(source->first);
|
||||
++source;
|
||||
}
|
||||
// VFALCO What if there are validations
|
||||
// for the ledger AFTER this one in the map?
|
||||
items_.clear();
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -1,149 +0,0 @@
|
||||
//------------------------------------------------------------------------------
|
||||
/*
|
||||
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.
|
||||
*/
|
||||
//==============================================================================
|
||||
|
||||
#include <BeastConfig.h>
|
||||
#include <ripple/validators/impl/ConnectionImp.h>
|
||||
#include <ripple/validators/impl/Logic.h>
|
||||
|
||||
/*
|
||||
|
||||
Questions the code should answer:
|
||||
|
||||
Most important thing that we do:
|
||||
Determine the new last fully validated ledger
|
||||
|
||||
|
||||
|
||||
- Are we robustly connected to the Ripple network?
|
||||
|
||||
- Given a new recent validation for a ledger with a sequence number higher
|
||||
than the last fully validated ledger, do we have a new last fully validated
|
||||
ledger?
|
||||
|
||||
- What's the latest fully validated ledger?
|
||||
|
||||
Sequence number must always be known to set a fully validated ledger
|
||||
|
||||
Accumulate validations from nodes you trust at least a little bit,
|
||||
and that aren't stale.
|
||||
|
||||
If you have a last fully validated ledger then validations for ledgers
|
||||
with lower sequence numbers can be ignored.
|
||||
|
||||
Flow of validations recent in time for sequence numbers greater or equal than
|
||||
the last fully validated ledger.
|
||||
|
||||
- What ledger is the current consenus round built on?
|
||||
|
||||
- Determine when the current consensus round is over?
|
||||
Criteria: Number of validations for a ledger that comes after.
|
||||
|
||||
*/
|
||||
|
||||
namespace ripple {
|
||||
namespace Validators {
|
||||
|
||||
Logic::Logic (Store& store, beast::Journal journal)
|
||||
: /*store_ (store)
|
||||
, */journal_ (journal)
|
||||
, ledgers_(stopwatch())
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
Logic::stop()
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
Logic::load()
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
Logic::add (ConnectionImp& c)
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(mutex_);
|
||||
connections_.insert(&c);
|
||||
}
|
||||
|
||||
void
|
||||
Logic::remove (ConnectionImp& c)
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(mutex_);
|
||||
connections_.erase(&c);
|
||||
}
|
||||
|
||||
bool
|
||||
Logic::isStale (STValidation const& v)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
void
|
||||
Logic::onTimer()
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(mutex_);
|
||||
beast::expire(ledgers_, std::chrono::minutes(5));
|
||||
}
|
||||
|
||||
void
|
||||
Logic::onValidation (STValidation const& v)
|
||||
{
|
||||
assert(v.isFieldPresent (sfLedgerSequence));
|
||||
auto const seq_no =
|
||||
v.getFieldU32 (sfLedgerSequence);
|
||||
auto const key = v.getSignerPublic();
|
||||
auto const ledger = v.getLedgerHash();
|
||||
|
||||
std::lock_guard<std::mutex> lock(mutex_);
|
||||
if (journal_.trace) journal_.trace <<
|
||||
"onValidation: " << ledger;
|
||||
auto const result = ledgers_.emplace (std::piecewise_construct,
|
||||
std::make_tuple(ledger), std::make_tuple());
|
||||
auto& meta = result.first->second;
|
||||
assert(result.second || seq_no == meta.seq_no);
|
||||
if (result.second)
|
||||
meta.seq_no = seq_no;
|
||||
meta.keys.insert (v.getSignerPublic());
|
||||
if (meta.seq_no > latest_.second.seq_no)
|
||||
{
|
||||
if (policy_.acceptLedgerMeta (*result.first))
|
||||
{
|
||||
//ledgers_.clear();
|
||||
latest_ = *result.first;
|
||||
if (journal_.info) journal_.info <<
|
||||
"Accepted " << latest_.second.seq_no <<
|
||||
" (" << ledger << ")";
|
||||
for (auto& _ : connections_)
|
||||
_->onLedger(latest_.first);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
Logic::onLedgerClosed (LedgerIndex index,
|
||||
LedgerHash const& hash, LedgerHash const& parent)
|
||||
{
|
||||
if (journal_.info) journal_.info <<
|
||||
"onLedgerClosed: " << index << " " << hash << " (parent " << parent << ")";
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,113 +0,0 @@
|
||||
//------------------------------------------------------------------------------
|
||||
/*
|
||||
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_LOGIC_H_INCLUDED
|
||||
#define RIPPLE_VALIDATORS_LOGIC_H_INCLUDED
|
||||
|
||||
#include <ripple/protocol/Protocol.h>
|
||||
#include <ripple/basics/hardened_hash.h>
|
||||
#include <ripple/basics/chrono.h>
|
||||
#include <ripple/protocol/RippleLedgerHash.h>
|
||||
#include <ripple/validators/impl/Store.h>
|
||||
#include <ripple/validators/impl/Tuning.h>
|
||||
#include <beast/container/aged_container_utility.h>
|
||||
#include <beast/container/aged_unordered_map.h>
|
||||
#include <beast/container/aged_unordered_set.h>
|
||||
#include <beast/smart_ptr/SharedPtr.h>
|
||||
#include <beast/utility/Journal.h>
|
||||
#include <boost/container/flat_set.hpp>
|
||||
#include <memory>
|
||||
#include <mutex>
|
||||
|
||||
namespace ripple {
|
||||
namespace Validators {
|
||||
|
||||
class ConnectionImp;
|
||||
|
||||
class Logic
|
||||
{
|
||||
private:
|
||||
struct LedgerMeta
|
||||
{
|
||||
std::uint32_t seq_no = 0;
|
||||
std::unordered_set<RippleAddress,
|
||||
hardened_hash<>> keys;
|
||||
};
|
||||
|
||||
class Policy
|
||||
{
|
||||
public:
|
||||
/** Returns `true` if we should accept this as the last validated. */
|
||||
bool
|
||||
acceptLedgerMeta (std::pair<LedgerHash const, LedgerMeta> const& value)
|
||||
{
|
||||
return value.second.keys.size() >= 3; // quorum
|
||||
}
|
||||
};
|
||||
|
||||
std::mutex mutex_;
|
||||
//Store& store_;
|
||||
beast::Journal journal_;
|
||||
|
||||
Policy policy_;
|
||||
beast::aged_unordered_map <LedgerHash, LedgerMeta,
|
||||
std::chrono::steady_clock, hardened_hash<>> ledgers_;
|
||||
std::pair<LedgerHash, LedgerMeta> latest_; // last fully validated
|
||||
boost::container::flat_set<ConnectionImp*> connections_;
|
||||
|
||||
//boost::container::flat_set<
|
||||
|
||||
public:
|
||||
explicit
|
||||
Logic (Store& store, beast::Journal journal);
|
||||
|
||||
beast::Journal const&
|
||||
journal() const
|
||||
{
|
||||
return journal_;
|
||||
}
|
||||
|
||||
void stop();
|
||||
|
||||
void load();
|
||||
|
||||
void
|
||||
add (ConnectionImp& c);
|
||||
|
||||
void
|
||||
remove (ConnectionImp& c);
|
||||
|
||||
bool
|
||||
isStale (STValidation const& v);
|
||||
|
||||
void
|
||||
onTimer();
|
||||
|
||||
void
|
||||
onValidation (STValidation const& v);
|
||||
|
||||
void
|
||||
onLedgerClosed (LedgerIndex index,
|
||||
LedgerHash const& hash, LedgerHash const& parent);
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -1,36 +0,0 @@
|
||||
//------------------------------------------------------------------------------
|
||||
/*
|
||||
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_STORE_H_INCLUDED
|
||||
#define RIPPLE_VALIDATORS_STORE_H_INCLUDED
|
||||
|
||||
namespace ripple {
|
||||
namespace Validators {
|
||||
|
||||
/** Abstract persistence for Validators data. */
|
||||
class Store
|
||||
{
|
||||
public:
|
||||
virtual ~Store() = default;
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -1,46 +0,0 @@
|
||||
//------------------------------------------------------------------------------
|
||||
/*
|
||||
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.
|
||||
*/
|
||||
//==============================================================================
|
||||
|
||||
#include <BeastConfig.h>
|
||||
#include <ripple/validators/impl/StoreSqdb.h>
|
||||
#include <beast/module/core/text/LexicalCast.h>
|
||||
#include <beast/utility/Debug.h>
|
||||
#include <boost/regex.hpp>
|
||||
|
||||
namespace ripple {
|
||||
namespace Validators {
|
||||
|
||||
StoreSqdb::StoreSqdb (beast::Journal journal)
|
||||
: m_journal (journal)
|
||||
{
|
||||
}
|
||||
|
||||
StoreSqdb::~StoreSqdb ()
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
StoreSqdb::open (SociConfig const& sociConfig)
|
||||
{
|
||||
m_journal.info << "Opening " << sociConfig.connectionString ();
|
||||
sociConfig.open (m_session);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,57 +0,0 @@
|
||||
//------------------------------------------------------------------------------
|
||||
/*
|
||||
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_STORESQDB_H_INCLUDED
|
||||
#define RIPPLE_VALIDATORS_STORESQDB_H_INCLUDED
|
||||
|
||||
#include <ripple/validators/impl/Store.h>
|
||||
#include <beast/module/core/files/File.h>
|
||||
#include <beast/utility/Journal.h>
|
||||
#include <ripple/core/SociDB.h>
|
||||
|
||||
namespace ripple {
|
||||
namespace Validators {
|
||||
|
||||
/** Database persistence for Validators using SQLite */
|
||||
class StoreSqdb : public Store
|
||||
{
|
||||
private:
|
||||
beast::Journal m_journal;
|
||||
soci::session m_session;
|
||||
|
||||
public:
|
||||
enum
|
||||
{
|
||||
// This affects the format of the data!
|
||||
currentSchemaVersion = 1
|
||||
};
|
||||
|
||||
explicit
|
||||
StoreSqdb (beast::Journal journal);
|
||||
|
||||
~StoreSqdb();
|
||||
|
||||
void
|
||||
open (SociConfig const& sociConfig);
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -1,29 +0,0 @@
|
||||
//------------------------------------------------------------------------------
|
||||
/*
|
||||
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_TUNING_H_INCLUDED
|
||||
#define RIPPLE_VALIDATORS_TUNING_H_INCLUDED
|
||||
|
||||
namespace ripple {
|
||||
namespace Validators {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -1,43 +0,0 @@
|
||||
//------------------------------------------------------------------------------
|
||||
/*
|
||||
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_MAKE_MANAGER_H_INCLUDED
|
||||
#define RIPPLE_VALIDATORS_MAKE_MANAGER_H_INCLUDED
|
||||
|
||||
#include <ripple/validators/ValidatorManager.h>
|
||||
#include <beast/threads/Stoppable.h>
|
||||
#include <beast/utility/Journal.h>
|
||||
#include <beast/module/core/files/File.h>
|
||||
#include <boost/asio/io_service.hpp>
|
||||
#include <memory>
|
||||
|
||||
namespace ripple {
|
||||
class BasicConfig;
|
||||
namespace Validators {
|
||||
|
||||
std::unique_ptr<Manager>
|
||||
make_Manager (beast::Stoppable& stoppableParent,
|
||||
boost::asio::io_service& io_service,
|
||||
beast::Journal journal,
|
||||
BasicConfig const& config);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -1,39 +0,0 @@
|
||||
//------------------------------------------------------------------------------
|
||||
/*
|
||||
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.
|
||||
*/
|
||||
//==============================================================================
|
||||
|
||||
#include <BeastConfig.h>
|
||||
#include <beast/unit_test/suite.h>
|
||||
|
||||
namespace ripple {
|
||||
namespace Validators {
|
||||
|
||||
class Validators_test : public beast::unit_test::suite
|
||||
{
|
||||
public:
|
||||
void
|
||||
run()
|
||||
{
|
||||
pass();
|
||||
}
|
||||
};
|
||||
|
||||
BEAST_DEFINE_TESTSUITE_MANUAL(Validators,validators,ripple);
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user