Bitcoin ABC 0.30.7
P2P Digital Currency
Classes | Public Member Functions | Private Attributes | List of all members
Epoch Class Reference

Epoch: RAII-style guard for using epoch-based graph traversal algorithms. More...

#include <epochguard.h>

Classes

class  Guard
 
class  Marker
 

Public Member Functions

 Epoch ()=default
 
 Epoch (const Epoch &)=delete
 
Epochoperator= (const Epoch &)=delete
 
 Epoch (Epoch &&)=delete
 
Epochoperator= (Epoch &&)=delete
 
 ~Epoch ()=default
 
bool guarded () const
 
bool visited (Marker &marker) const EXCLUSIVE_LOCKS_REQUIRED(*this)
 

Private Attributes

uint64_t m_raw_epoch = 0
 
bool m_guarded = false
 

Detailed Description

Epoch: RAII-style guard for using epoch-based graph traversal algorithms.

When walking ancestors or descendants, we generally want to avoid visiting the same transactions twice. Some traversal algorithms use std::set (or setEntries) to deduplicate the transaction we visit. However, use of std::set is algorithmically undesirable because it both adds an asymptotic factor of O(log n) to traversals cost and triggers O(n) more dynamic memory allocations. In many algorithms we can replace std::set with an internal mempool counter to track the time (or, "epoch") that we began a traversal, and check + update a per-transaction epoch for each transaction we look at to determine if that transaction has not yet been visited during the current traversal's epoch. Algorithms using std::set can be replaced on a one by one basis. Both techniques are not fundamentally incompatible across the codebase. Generally speaking, however, the remaining use of std::set for mempool traversal should be viewed as a TODO for replacement with an epoch based traversal, rather than a preference for std::set over epochs in that algorithm.

Definition at line 35 of file epochguard.h.

Constructor & Destructor Documentation

◆ Epoch() [1/3]

Epoch::Epoch ( )
default

◆ Epoch() [2/3]

Epoch::Epoch ( const Epoch )
delete

◆ Epoch() [3/3]

Epoch::Epoch ( Epoch &&  )
delete

◆ ~Epoch()

Epoch::~Epoch ( )
default

Member Function Documentation

◆ guarded()

bool Epoch::guarded ( ) const
inline

Definition at line 48 of file epochguard.h.

◆ operator=() [1/2]

Epoch & Epoch::operator= ( const Epoch )
delete

◆ operator=() [2/2]

Epoch & Epoch::operator= ( Epoch &&  )
delete

◆ visited()

bool Epoch::visited ( Marker marker) const
inline

Definition at line 85 of file epochguard.h.

Here is the call graph for this function:

Member Data Documentation

◆ m_guarded

bool Epoch::m_guarded = false
private

Definition at line 38 of file epochguard.h.

◆ m_raw_epoch

uint64_t Epoch::m_raw_epoch = 0
private

Definition at line 37 of file epochguard.h.


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