rippled
Public Types | Public Member Functions | Private Member Functions | Private Attributes | List of all members
ripple::NodeStore::DeterministicShard Class Reference

DeterministicShard class. More...

Collaboration diagram for ripple::NodeStore::DeterministicShard:
Collaboration graph
[legend]

Public Types

using nodeptr = std::shared_ptr< NodeObject >
 

Public Member Functions

 DeterministicShard (DeterministicShard const &)=delete
 
DeterministicShardoperator= (DeterministicShard const &)=delete
 
 DeterministicShard (Application &app, DatabaseShard const &db, std::uint32_t index, uint256 const &lastHash, beast::Journal j)
 Creates the object for shard database. More...
 
 ~DeterministicShard ()
 
bool init ()
 Initializes the deterministic shard. More...
 
void close (bool cancel=false)
 Finalizes and closes the shard. More...
 
void store (nodeptr nobj)
 Store the object into memory pool. More...
 
void flush ()
 Flush all objects from memory pool to shard. More...
 

Private Member Functions

uint160 hash (const uint256 &lastHash) const
 
std::uint64_t digest (int n) const
 

Private Attributes

bool inited_
 
std::set< nodeptr, std::function< bool(nodeptr, nodeptr)> > nodeset_
 
Applicationapp_
 
DatabaseShard const & db_
 
const std::uint32_t index_
 
const uint160 hash_
 
const boost::filesystem::path tempdir_
 
const boost::filesystem::path finaldir_
 
DummyScheduler scheduler_
 
std::unique_ptr< nudb::context > ctx_
 
std::shared_ptr< Backendbackend_
 
const beast::Journal j_
 

Detailed Description

DeterministicShard class.

  1. The init() method creates temporary folder tempdir_, and the deterministic shard is initialized in that folder.
  2. The store() method adds object to memory pool.
  3. The flush() method stores all objects from memory pool to the shard located in tempdir_ in sorted order.
  4. The close(true) method finalizes the shard and moves it from tempdir_ temporary folder to filandir_ permanent folder, deleting old (non-deterministic) shard located in finaldir_.

Definition at line 42 of file DeterministicShard.h.

Member Typedef Documentation

◆ nodeptr

Definition at line 45 of file DeterministicShard.h.

Constructor & Destructor Documentation

◆ DeterministicShard() [1/2]

ripple::NodeStore::DeterministicShard::DeterministicShard ( DeterministicShard const &  )
delete

◆ DeterministicShard() [2/2]

ripple::NodeStore::DeterministicShard::DeterministicShard ( Application app,
DatabaseShard const &  db,
std::uint32_t  index,
uint256 const &  lastHash,
beast::Journal  j 
)

Creates the object for shard database.

Parameters
appApplication object
dbShard Database which deterministic shard belongs to
indexIndex of the shard
lastHashHash of last ledger in the shard
jJournal to logging

Definition at line 35 of file DeterministicShard.cpp.

◆ ~DeterministicShard()

ripple::NodeStore::DeterministicShard::~DeterministicShard ( )

Definition at line 54 of file DeterministicShard.cpp.

Member Function Documentation

◆ operator=()

DeterministicShard& ripple::NodeStore::DeterministicShard::operator= ( DeterministicShard const &  )
delete

◆ init()

bool ripple::NodeStore::DeterministicShard::init ( )

Initializes the deterministic shard.

Returns
true is success, false if errored

Definition at line 100 of file DeterministicShard.cpp.

◆ close()

void ripple::NodeStore::DeterministicShard::close ( bool  cancel = false)

Finalizes and closes the shard.

Parameters
cancelTrue if reject the shard and delete all files, false if finalize the shard and store them

Definition at line 163 of file DeterministicShard.cpp.

◆ store()

void ripple::NodeStore::DeterministicShard::store ( nodeptr  nobj)

Store the object into memory pool.

Parameters
nobjObject to store.

Definition at line 183 of file DeterministicShard.cpp.

◆ flush()

void ripple::NodeStore::DeterministicShard::flush ( )

Flush all objects from memory pool to shard.

Definition at line 192 of file DeterministicShard.cpp.

◆ hash()

uint160 ripple::NodeStore::DeterministicShard::hash ( const uint256 lastHash) const
private

Definition at line 60 of file DeterministicShard.cpp.

◆ digest()

std::uint64_t ripple::NodeStore::DeterministicShard::digest ( int  n) const
private

Definition at line 76 of file DeterministicShard.cpp.

Member Data Documentation

◆ inited_

bool ripple::NodeStore::DeterministicShard::inited_
private

Definition at line 105 of file DeterministicShard.h.

◆ nodeset_

std::set<nodeptr, std::function<bool(nodeptr, nodeptr)> > ripple::NodeStore::DeterministicShard::nodeset_
private

Definition at line 108 of file DeterministicShard.h.

◆ app_

Application& ripple::NodeStore::DeterministicShard::app_
private

Definition at line 111 of file DeterministicShard.h.

◆ db_

DatabaseShard const& ripple::NodeStore::DeterministicShard::db_
private

Definition at line 114 of file DeterministicShard.h.

◆ index_

const std::uint32_t ripple::NodeStore::DeterministicShard::index_
private

Definition at line 117 of file DeterministicShard.h.

◆ hash_

const uint160 ripple::NodeStore::DeterministicShard::hash_
private

Definition at line 120 of file DeterministicShard.h.

◆ tempdir_

const boost::filesystem::path ripple::NodeStore::DeterministicShard::tempdir_
private

Definition at line 123 of file DeterministicShard.h.

◆ finaldir_

const boost::filesystem::path ripple::NodeStore::DeterministicShard::finaldir_
private

Definition at line 126 of file DeterministicShard.h.

◆ scheduler_

DummyScheduler ripple::NodeStore::DeterministicShard::scheduler_
private

Definition at line 129 of file DeterministicShard.h.

◆ ctx_

std::unique_ptr<nudb::context> ripple::NodeStore::DeterministicShard::ctx_
private

Definition at line 132 of file DeterministicShard.h.

◆ backend_

std::shared_ptr<Backend> ripple::NodeStore::DeterministicShard::backend_
private

Definition at line 135 of file DeterministicShard.h.

◆ j_

const beast::Journal ripple::NodeStore::DeterministicShard::j_
private

Definition at line 138 of file DeterministicShard.h.