8 #include <boost/assert.hpp> 16 ReputationRepositoryImpl::ReputationRepositoryImpl(
17 std::shared_ptr<libp2p::basic::Scheduler> scheduler)
18 : scheduler_{std::move(scheduler)},
35 "Reputation of peer {} was changed by {} points to {} points. " 47 std::chrono::seconds duration) {
50 "Reputation of peer {} was changed by {} points to {} points " 51 "for {} seconds. Reason: `{}'",
59 -
static_cast<double>(diff.
value)
60 * std::pow(0.98, duration.count())
65 [wp = weak_from_this(), peer_id, value, reason = diff.
reason] {
66 if (auto self = wp.lock()) {
67 auto reputation = self->reputation_table_[peer_id] += value;
69 "Reputation of peer {} was changed by {} points to {} " 70 "points. Reason: reverse of `{}'",
90 auto &peer_id = cit->first;
104 "Reputation of peer {} was changed by {} points to {} points by tick",
libp2p::peer::PeerId PeerId
std::shared_ptr< libp2p::basic::Scheduler > scheduler_
Reputation reputation(const PeerId &peer_id) const override
Current peer reputation.
Reputation changeForATime(const PeerId &peer_id, ReputationChange diff, std::chrono::seconds duration) override
Reputation change(const PeerId &peer_id, ReputationChange diff) override
libp2p::basic::Scheduler::Handle tick_handler_
const std::string_view reason
std::unordered_map< PeerId, Reputation > reputation_table_
Logger createLogger(const std::string &tag)