Kagome
Polkadot Runtime Engine in C++17
kagome::transaction_pool::PoolModeratorImpl Class Reference

#include <pool_moderator_impl.hpp>

Inheritance diagram for kagome::transaction_pool::PoolModeratorImpl:
Collaboration diagram for kagome::transaction_pool::PoolModeratorImpl:

Classes

struct  Params
 

Public Member Functions

 PoolModeratorImpl (std::shared_ptr< clock::SystemClock > clock, Params parameters)
 
 ~PoolModeratorImpl () override=default
 
void ban (const common::Hash256 &tx_hash) override
 
bool banIfStale (primitives::BlockNumber current_block, const Transaction &tx) override
 
bool isBanned (const common::Hash256 &tx_hash) const override
 
void updateBan () override
 
size_t bannedNum () const override
 
- Public Member Functions inherited from kagome::transaction_pool::PoolModerator
virtual ~PoolModerator ()=default
 
virtual bool isBanned (const Transaction::Hash &tx_hash) const =0
 

Static Public Attributes

static constexpr size_t kDefaultExpectedSize = 2048
 
static constexpr clock::SystemClock::Duration kDefaultBanFor
 

Private Types

using Map = std::map< common::Hash256, clock::SystemClock::TimePoint >
 

Private Attributes

std::shared_ptr< clock::SystemClockclock_
 
Params params_
 
Map banned_until_
 

Detailed Description

Definition at line 17 of file pool_moderator_impl.hpp.


Class Documentation

struct kagome::transaction_pool::PoolModeratorImpl::Params
Parameters
ban_foramount of time for which a transaction is banned
expected_sizeexpected maximum number of banned transactions. If significantly exceeded, some transactions will be removed from ban list

Definition at line 37 of file pool_moderator_impl.hpp.

Collaboration diagram for kagome::transaction_pool::PoolModeratorImpl::Params:
Class Members
Duration ban_for
size_t expected_size

Member Typedef Documentation

Constructor & Destructor Documentation

kagome::transaction_pool::PoolModeratorImpl::PoolModeratorImpl ( std::shared_ptr< clock::SystemClock clock,
Params  parameters 
)
Parameters
parametersconfiguration of the pool moderator
clocka clock used to determine when it is time to unban a transaction

Definition at line 12 of file pool_moderator_impl.cpp.

kagome::transaction_pool::PoolModeratorImpl::~PoolModeratorImpl ( )
overridedefault

Member Function Documentation

void kagome::transaction_pool::PoolModeratorImpl::ban ( const common::Hash256 tx_hash)
overridevirtual

Bans a transaction for a fixed amount of time

Parameters
tx_hash

Implements kagome::transaction_pool::PoolModerator.

Definition at line 16 of file pool_moderator_impl.cpp.

bool kagome::transaction_pool::PoolModeratorImpl::banIfStale ( primitives::BlockNumber  current_block,
const Transaction &  tx 
)
overridevirtual

Bans a transaction

Parameters
txif its longevity is past
current_block
Returns
true if the transaction has been banned, false otherwise

Implements kagome::transaction_pool::PoolModerator.

Definition at line 25 of file pool_moderator_impl.cpp.

size_t kagome::transaction_pool::PoolModeratorImpl::bannedNum ( ) const
overridevirtual

Return the number of currently banned transactions

Implements kagome::transaction_pool::PoolModerator.

Definition at line 55 of file pool_moderator_impl.cpp.

bool kagome::transaction_pool::PoolModeratorImpl::isBanned ( const common::Hash256 tx_hash) const
override

Definition at line 34 of file pool_moderator_impl.cpp.

void kagome::transaction_pool::PoolModeratorImpl::updateBan ( )
overridevirtual

Unbans transaction which ban time is exceeded

Implements kagome::transaction_pool::PoolModerator.

Definition at line 44 of file pool_moderator_impl.cpp.

Member Data Documentation

Map kagome::transaction_pool::PoolModeratorImpl::banned_until_
private

Definition at line 66 of file pool_moderator_impl.hpp.

std::shared_ptr<clock::SystemClock> kagome::transaction_pool::PoolModeratorImpl::clock_
private

Definition at line 64 of file pool_moderator_impl.hpp.

constexpr clock::SystemClock::Duration kagome::transaction_pool::PoolModeratorImpl::kDefaultBanFor
static
Initial value:
=
std::chrono::minutes(30)

Default ban duration

Definition at line 29 of file pool_moderator_impl.hpp.

constexpr size_t kagome::transaction_pool::PoolModeratorImpl::kDefaultExpectedSize = 2048
static

Default value of expected size parameter

Definition at line 24 of file pool_moderator_impl.hpp.

Params kagome::transaction_pool::PoolModeratorImpl::params_
private

Definition at line 65 of file pool_moderator_impl.hpp.


The documentation for this class was generated from the following files: