Ethereum  PoC-8
The C++ Implementation of Ethereum
dev::GenericTrieDB< _DB > Class Template Reference

Merkle Patricia Tree "Trie": a modifed base-16 Radix tree. This version uses a database backend. Usage: More...

#include <TrieDB.h>

Inheritance diagram for dev::GenericTrieDB< _DB >:
dev::SpecificTrieDB< GenericTrieDB< _DB >, h256 > dev::FatGenericTrieDB< _DB > dev::HashedGenericTrieDB< _DB >

Classes

class  iterator
 

Public Types

using DB = _DB
 

Public Member Functions

 GenericTrieDB (DB *_db=nullptr)
 
 GenericTrieDB (DB *_db, h256 const &_root, Verification _v=Verification::Normal)
 
 ~GenericTrieDB ()
 
void open (DB *_db)
 
void open (DB *_db, h256 const &_root, Verification _v=Verification::Normal)
 
void init ()
 
void setRoot (h256 const &_root, Verification _v=Verification::Normal)
 
bool isNull () const
 True if the trie is uninitialised (i.e. that the DB doesn't contain the root node). More...
 
bool isEmpty () const
 True if the trie is initialised but empty (i.e. that the DB contains the root node which is empty). More...
 
h256 const & root () const
 
std::string at (bytes const &_key) const
 
std::string at (bytesConstRef _key) const
 
void insert (bytes const &_key, bytes const &_value)
 
void insert (bytesConstRef _key, bytes const &_value)
 
void insert (bytes const &_key, bytesConstRef _value)
 
void insert (bytesConstRef _key, bytesConstRef _value)
 
void remove (bytes const &_key)
 
void remove (bytesConstRef _key)
 
bool contains (bytes const &_key) const
 
bool contains (bytesConstRef _key) const
 
iterator begin () const
 
iterator end () const
 
iterator lower_bound (bytesConstRef _key) const
 
void descendKey (h256 const &_k, h256Hash &_keyMask, bool _wasExt, std::ostream *_out, int _indent=0) const
 Used for debugging, scans the whole trie. More...
 
void descendEntry (RLP const &_r, h256Hash &_keyMask, bool _wasExt, std::ostream *_out, int _indent) const
 Used for debugging, scans the whole trie. More...
 
void descendList (RLP const &_r, h256Hash &_keyMask, bool _wasExt, std::ostream *_out, int _indent) const
 Used for debugging, scans the whole trie. More...
 
h256Hash leftOvers (std::ostream *_out=nullptr) const
 Used for debugging, scans the whole trie. More...
 
void debugStructure (std::ostream &_out) const
 Used for debugging, scans the whole trie. More...
 
bool check (bool _requireNoLeftOvers) const
 
DB const * db () const
 
DBdb ()
 

Detailed Description

template<class _DB>
class dev::GenericTrieDB< _DB >

Merkle Patricia Tree "Trie": a modifed base-16 Radix tree. This version uses a database backend. Usage:

GenericTrieDB<MyDB> t(&myDB);
assert(t.isNull());
t.init();
assert(t.isEmpty());
t.insert(x, y);
assert(t.at(x) == y.toString());
t.remove(x);
assert(t.isEmpty());

Definition at line 56 of file TrieDB.h.

Member Typedef Documentation

◆ DB

template<class _DB >
using dev::GenericTrieDB< _DB >::DB = _DB

Definition at line 59 of file TrieDB.h.

Constructor & Destructor Documentation

◆ GenericTrieDB() [1/2]

template<class _DB >
dev::GenericTrieDB< _DB >::GenericTrieDB ( DB _db = nullptr)
inlineexplicit

Definition at line 61 of file TrieDB.h.

◆ GenericTrieDB() [2/2]

template<class _DB >
dev::GenericTrieDB< _DB >::GenericTrieDB ( DB _db,
h256 const &  _root,
Verification  _v = Verification::Normal 
)
inline

Definition at line 62 of file TrieDB.h.

◆ ~GenericTrieDB()

template<class _DB >
dev::GenericTrieDB< _DB >::~GenericTrieDB ( )
inline

Definition at line 63 of file TrieDB.h.

Member Function Documentation

◆ at() [1/2]

template<class _DB >
std::string dev::GenericTrieDB< _DB >::at ( bytes const &  _key) const
inline

Definition at line 95 of file TrieDB.h.

◆ at() [2/2]

template<class DB >
std::string dev::GenericTrieDB< DB >::at ( bytesConstRef  _key) const

Definition at line 791 of file TrieDB.h.

◆ begin()

template<class _DB >
iterator dev::GenericTrieDB< _DB >::begin ( ) const
inline

Definition at line 150 of file TrieDB.h.

◆ check()

template<class _DB >
bool dev::GenericTrieDB< _DB >::check ( bool  _requireNoLeftOvers) const
inline

Used for debugging, scans the whole trie.

Parameters
_requireNoLeftOversif true, requires that all keys are reachable.

Definition at line 216 of file TrieDB.h.

◆ contains() [1/2]

template<class _DB >
bool dev::GenericTrieDB< _DB >::contains ( bytes const &  _key) const
inline

Definition at line 103 of file TrieDB.h.

◆ contains() [2/2]

template<class _DB >
bool dev::GenericTrieDB< _DB >::contains ( bytesConstRef  _key) const
inline

Definition at line 104 of file TrieDB.h.

◆ db() [1/2]

template<class _DB >
DB* dev::GenericTrieDB< _DB >::db ( )
inline

Definition at line 233 of file TrieDB.h.

◆ db() [2/2]

template<class _DB >
DB const* dev::GenericTrieDB< _DB >::db ( ) const
inline

Get the underlying database.

Warning
This can be used to bypass the trie code. Don't use these unless you really know what you're doing.

Definition at line 232 of file TrieDB.h.

◆ debugStructure()

template<class _DB >
void dev::GenericTrieDB< _DB >::debugStructure ( std::ostream &  _out) const
inline

Used for debugging, scans the whole trie.

Definition at line 209 of file TrieDB.h.

◆ descendEntry()

template<class _DB >
void dev::GenericTrieDB< _DB >::descendEntry ( RLP const &  _r,
h256Hash _keyMask,
bool  _wasExt,
std::ostream *  _out,
int  _indent 
) const
inline

Used for debugging, scans the whole trie.

Definition at line 167 of file TrieDB.h.

◆ descendKey()

template<class _DB >
void dev::GenericTrieDB< _DB >::descendKey ( h256 const &  _k,
h256Hash _keyMask,
bool  _wasExt,
std::ostream *  _out,
int  _indent = 0 
) const
inline

Used for debugging, scans the whole trie.

Definition at line 156 of file TrieDB.h.

◆ descendList()

template<class _DB >
void dev::GenericTrieDB< _DB >::descendList ( RLP const &  _r,
h256Hash _keyMask,
bool  _wasExt,
std::ostream *  _out,
int  _indent 
) const
inline

Used for debugging, scans the whole trie.

Definition at line 179 of file TrieDB.h.

◆ end()

template<class _DB >
iterator dev::GenericTrieDB< _DB >::end ( ) const
inline

Definition at line 151 of file TrieDB.h.

◆ init()

template<class _DB >
void dev::GenericTrieDB< _DB >::init ( )
inline

Definition at line 68 of file TrieDB.h.

◆ insert() [1/4]

template<class _DB >
void dev::GenericTrieDB< _DB >::insert ( bytes const &  _key,
bytes const &  _value 
)
inline

Definition at line 97 of file TrieDB.h.

◆ insert() [2/4]

template<class _DB >
void dev::GenericTrieDB< _DB >::insert ( bytes const &  _key,
bytesConstRef  _value 
)
inline

Definition at line 99 of file TrieDB.h.

◆ insert() [3/4]

template<class _DB >
void dev::GenericTrieDB< _DB >::insert ( bytesConstRef  _key,
bytes const &  _value 
)
inline

Definition at line 98 of file TrieDB.h.

◆ insert() [4/4]

template<class DB >
void dev::GenericTrieDB< DB >::insert ( bytesConstRef  _key,
bytesConstRef  _value 
)

Definition at line 777 of file TrieDB.h.

◆ isEmpty()

template<class _DB >
bool dev::GenericTrieDB< _DB >::isEmpty ( ) const
inline

True if the trie is initialised but empty (i.e. that the DB contains the root node which is empty).

Definition at line 86 of file TrieDB.h.

◆ isNull()

template<class _DB >
bool dev::GenericTrieDB< _DB >::isNull ( ) const
inline

True if the trie is uninitialised (i.e. that the DB doesn't contain the root node).

Definition at line 84 of file TrieDB.h.

◆ leftOvers()

template<class _DB >
h256Hash dev::GenericTrieDB< _DB >::leftOvers ( std::ostream *  _out = nullptr) const
inline

Used for debugging, scans the whole trie.

Definition at line 201 of file TrieDB.h.

◆ lower_bound()

template<class _DB >
iterator dev::GenericTrieDB< _DB >::lower_bound ( bytesConstRef  _key) const
inline

Definition at line 153 of file TrieDB.h.

◆ open() [1/2]

template<class _DB >
void dev::GenericTrieDB< _DB >::open ( DB _db)
inline

Definition at line 65 of file TrieDB.h.

◆ open() [2/2]

template<class _DB >
void dev::GenericTrieDB< _DB >::open ( DB _db,
h256 const &  _root,
Verification  _v = Verification::Normal 
)
inline

Definition at line 66 of file TrieDB.h.

◆ remove() [1/2]

template<class _DB >
void dev::GenericTrieDB< _DB >::remove ( bytes const &  _key)
inline

Definition at line 101 of file TrieDB.h.

◆ remove() [2/2]

template<class DB >
void dev::GenericTrieDB< DB >::remove ( bytesConstRef  _key)

Definition at line 924 of file TrieDB.h.

◆ root()

template<class _DB >
h256 const& dev::GenericTrieDB< _DB >::root ( ) const
inline

Definition at line 88 of file TrieDB.h.

◆ setRoot()

template<class _DB >
void dev::GenericTrieDB< _DB >::setRoot ( h256 const &  _root,
Verification  _v = Verification::Normal 
)
inline

Definition at line 70 of file TrieDB.h.


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