mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-20 11:05:54 +00:00
fixes windows tests
This commit is contained in:
@@ -457,7 +457,6 @@ public:
|
|||||||
class PeerSim : public PeerPartial, public std::enable_shared_from_this<PeerSim>
|
class PeerSim : public PeerPartial, public std::enable_shared_from_this<PeerSim>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
using id_t = Peer::id_t;
|
|
||||||
PeerSim(Overlay& overlay, beast::Journal journal)
|
PeerSim(Overlay& overlay, beast::Journal journal)
|
||||||
: overlay_(overlay), squelch_(journal, overlay_.clock())
|
: overlay_(overlay), squelch_(journal, overlay_.clock())
|
||||||
{
|
{
|
||||||
@@ -466,7 +465,7 @@ public:
|
|||||||
|
|
||||||
~PeerSim() = default;
|
~PeerSim() = default;
|
||||||
|
|
||||||
id_t
|
Peer::id_t
|
||||||
id() const override
|
id() const override
|
||||||
{
|
{
|
||||||
return id_;
|
return id_;
|
||||||
@@ -504,8 +503,8 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
inline static id_t sid_ = 0;
|
inline static Peer::id_t sid_ = 0;
|
||||||
id_t id_;
|
Peer::id_t id_;
|
||||||
Overlay& overlay_;
|
Overlay& overlay_;
|
||||||
reduce_relay::Squelch squelch_;
|
reduce_relay::Squelch squelch_;
|
||||||
};
|
};
|
||||||
@@ -515,7 +514,6 @@ class OverlaySim : public Overlay, public reduce_relay::SquelchHandler
|
|||||||
using Peers = std::unordered_map<Peer::id_t, PeerSPtr>;
|
using Peers = std::unordered_map<Peer::id_t, PeerSPtr>;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
using id_t = Peer::id_t;
|
|
||||||
using clock_type = TestStopwatch;
|
using clock_type = TestStopwatch;
|
||||||
OverlaySim(Application& app)
|
OverlaySim(Application& app)
|
||||||
: slots_(app.logs(), *this, app.config(), clock_), logs_(app.logs())
|
: slots_(app.logs(), *this, app.config(), clock_), logs_(app.logs())
|
||||||
@@ -557,7 +555,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
deletePeer(id_t id, UnsquelchCB f) override
|
deletePeer(Peer::id_t id, UnsquelchCB f) override
|
||||||
{
|
{
|
||||||
unsquelch_ = f;
|
unsquelch_ = f;
|
||||||
slots_.deletePeer(id, true);
|
slots_.deletePeer(id, true);
|
||||||
@@ -641,14 +639,14 @@ public:
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::set<id_t>
|
std::set<Peer::id_t>
|
||||||
getSelected(PublicKey const& validator)
|
getSelected(PublicKey const& validator)
|
||||||
{
|
{
|
||||||
auto const& it = slots_.getSlots().find(validator);
|
auto const& it = slots_.getSlots().find(validator);
|
||||||
if (it == slots_.getSlots().end())
|
if (it == slots_.getSlots().end())
|
||||||
return {};
|
return {};
|
||||||
|
|
||||||
std::set<id_t> r;
|
std::set<Peer::id_t> r;
|
||||||
for (auto const& [id, info] : it->second.getPeers())
|
for (auto const& [id, info] : it->second.getPeers())
|
||||||
if (info.state == reduce_relay::PeerState::Selected)
|
if (info.state == reduce_relay::PeerState::Selected)
|
||||||
r.insert(id);
|
r.insert(id);
|
||||||
@@ -663,7 +661,7 @@ public:
|
|||||||
return selected.find(peer) != selected.end();
|
return selected.find(peer) != selected.end();
|
||||||
}
|
}
|
||||||
|
|
||||||
id_t
|
Peer::id_t
|
||||||
getSelectedPeer(PublicKey const& validator)
|
getSelectedPeer(PublicKey const& validator)
|
||||||
{
|
{
|
||||||
auto selected = getSelected(validator);
|
auto selected = getSelected(validator);
|
||||||
@@ -671,14 +669,14 @@ public:
|
|||||||
return *selected.begin();
|
return *selected.begin();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unordered_map<id_t, reduce_relay::Slot::PeerInfo>
|
std::unordered_map<Peer::id_t, reduce_relay::Slot::PeerInfo>
|
||||||
getPeers(PublicKey const& validator)
|
getPeers(PublicKey const& validator)
|
||||||
{
|
{
|
||||||
auto const& it = slots_.getSlots().find(validator);
|
auto const& it = slots_.getSlots().find(validator);
|
||||||
if (it == slots_.getSlots().end())
|
if (it == slots_.getSlots().end())
|
||||||
return {};
|
return {};
|
||||||
|
|
||||||
auto r = std::unordered_map<id_t, reduce_relay::Slot::PeerInfo>();
|
auto r = std::unordered_map<Peer::id_t, reduce_relay::Slot::PeerInfo>();
|
||||||
for (auto const& [id, info] : it->second.getPeers())
|
for (auto const& [id, info] : it->second.getPeers())
|
||||||
r.emplace(std::make_pair(id, info));
|
r.emplace(std::make_pair(id, info));
|
||||||
|
|
||||||
@@ -911,7 +909,6 @@ private:
|
|||||||
class base_squelch_test : public beast::unit_test::suite
|
class base_squelch_test : public beast::unit_test::suite
|
||||||
{
|
{
|
||||||
using Slot = reduce_relay::Slot;
|
using Slot = reduce_relay::Slot;
|
||||||
using id_t = Peer::id_t;
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void
|
void
|
||||||
|
|||||||
@@ -536,21 +536,21 @@ Slots::updateConsideredValidator(PublicKey const& validator, Peer::id_t peer)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
Slots::deletePeer(id_t id, bool erase)
|
Slots::deletePeer(Peer::id_t id, bool erase)
|
||||||
{
|
{
|
||||||
auto deletePeer = [&](slots_map& slots) {
|
auto const f = [&](slots_map& slots) {
|
||||||
for (auto& [validator, slot] : slots)
|
for (auto& [validator, slot] : slots)
|
||||||
slot.deletePeer(validator, id, erase);
|
slot.deletePeer(validator, id, erase);
|
||||||
};
|
};
|
||||||
|
|
||||||
deletePeer(slots_);
|
f(slots_);
|
||||||
deletePeer(untrustedSlots_);
|
f(untrustedSlots_);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
Slots::deleteIdlePeers()
|
Slots::deleteIdlePeers()
|
||||||
{
|
{
|
||||||
auto deleteSlots = [&](slots_map& slots) {
|
auto const f = [&](slots_map& slots) {
|
||||||
auto const now = clock_.now();
|
auto const now = clock_.now();
|
||||||
|
|
||||||
for (auto it = slots.begin(); it != slots.end();)
|
for (auto it = slots.begin(); it != slots.end();)
|
||||||
@@ -575,8 +575,8 @@ Slots::deleteIdlePeers()
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
deleteSlots(slots_);
|
f(slots_);
|
||||||
deleteSlots(untrustedSlots_);
|
f(untrustedSlots_);
|
||||||
|
|
||||||
// remove and squelch all validators that the selector deemed unsuitable
|
// remove and squelch all validators that the selector deemed unsuitable
|
||||||
// there might be some good validators in this set that "lapsed".
|
// there might be some good validators in this set that "lapsed".
|
||||||
|
|||||||
Reference in New Issue
Block a user