mirror of
https://github.com/Xahau/xahaud.git
synced 2025-12-06 17:27:52 +00:00
- Separate `Scheduler` from `BasicNetwork`. - Add an event/collector framework for monitoring invariants and calculating statistics. - Allow distinct network and trust connections between Peers. - Add a simple routing strategy to support broadcasting arbitrary messages. - Add a common directed graph (`Digraph`) class for representing network and trust topologies. - Add a `PeerGroup` class for simpler specification of the trust and network topologies. - Add a `LedgerOracle` class to ensure distinct ledger histories and simplify branch checking. - Add a `Submitter` to send transactions in at fixed or random intervals to fixed or random peers. Co-authored-by: Joseph McGee
77 lines
2.1 KiB
C++
77 lines
2.1 KiB
C++
//------------------------------------------------------------------------------
|
|
/*
|
|
This file is part of rippled: https://github.com/ripple/rippled
|
|
Copyright (c) 2012-2017 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 <test/csf/Sim.h>
|
|
|
|
namespace ripple {
|
|
namespace test {
|
|
namespace csf {
|
|
|
|
void
|
|
Sim::run(int ledgers)
|
|
{
|
|
for (auto& p : peers)
|
|
{
|
|
p.targetLedgers = p.completedLedgers + ledgers;
|
|
p.start();
|
|
}
|
|
scheduler.step();
|
|
}
|
|
|
|
void
|
|
Sim::run(SimDuration const & dur)
|
|
{
|
|
for (auto& p : peers)
|
|
{
|
|
p.targetLedgers = std::numeric_limits<decltype(p.targetLedgers)>::max();
|
|
p.start();
|
|
}
|
|
scheduler.step_for(dur);
|
|
}
|
|
|
|
bool
|
|
Sim::synchronized() const
|
|
{
|
|
if (peers.size() < 1)
|
|
return true;
|
|
Peer const& ref = peers.front();
|
|
return std::all_of(peers.begin(), peers.end(), [&ref](Peer const& p) {
|
|
return p.lastClosedLedger.id() ==
|
|
ref.lastClosedLedger.id() &&
|
|
p.fullyValidatedLedger.id() ==
|
|
ref.fullyValidatedLedger.id();
|
|
});
|
|
}
|
|
|
|
std::size_t
|
|
Sim::branches() const
|
|
{
|
|
if(peers.size() < 1)
|
|
return 0;
|
|
std::set<Ledger> ledgers;
|
|
for(auto const & peer : peers)
|
|
ledgers.insert(peer.fullyValidatedLedger);
|
|
|
|
return oracle.branches(ledgers);
|
|
}
|
|
|
|
} // namespace csf
|
|
} // namespace test
|
|
} // namespace ripple
|