rippled
Public Member Functions | Private Attributes | List of all members
ripple::ManifestCache Class Reference

Remembers manifests with the highest sequence number. More...

Collaboration diagram for ripple::ManifestCache:
Collaboration graph
[legend]

Public Member Functions

 ManifestCache (beast::Journal j=beast::Journal(beast::Journal::getNullSink()))
 
PublicKey getSigningKey (PublicKey const &pk) const
 Returns master key's current signing key. More...
 
PublicKey getMasterKey (PublicKey const &pk) const
 Returns ephemeral signing key's master public key. More...
 
boost::optional< std::uint32_tgetSequence (PublicKey const &pk) const
 Returns master key's current manifest sequence. More...
 
boost::optional< std::stringgetDomain (PublicKey const &pk) const
 Returns domain claimed by a given public key. More...
 
boost::optional< std::stringgetManifest (PublicKey const &pk) const
 Returns mainfest corresponding to a given public key. More...
 
bool revoked (PublicKey const &pk) const
 Returns true if master key has been revoked in a manifest. More...
 
ManifestDisposition applyManifest (Manifest m)
 Add manifest to cache. More...
 
bool load (DatabaseCon &dbCon, std::string const &dbTable, std::string const &configManifest, std::vector< std::string > const &configRevocation)
 Populate manifest cache with manifests in database and config. More...
 
void load (DatabaseCon &dbCon, std::string const &dbTable)
 Populate manifest cache with manifests in database. More...
 
void save (DatabaseCon &dbCon, std::string const &dbTable, std::function< bool(PublicKey const &)> isTrusted)
 Save cached manifests to database. More...
 
template<class Function >
void for_each_manifest (Function &&f) const
 Invokes the callback once for every populated manifest. More...
 
template<class PreFun , class EachFun >
void for_each_manifest (PreFun &&pf, EachFun &&f) const
 Invokes the callback once for every populated manifest. More...
 

Private Attributes

beast::Journal j_
 
std::mutex apply_mutex_
 
std::mutex read_mutex_
 
hash_map< PublicKey, Manifestmap_
 Active manifests stored by master public key. More...
 
hash_map< PublicKey, PublicKeysigningToMasterKeys_
 Master public keys stored by current ephemeral public key. More...
 

Detailed Description

Remembers manifests with the highest sequence number.

Definition at line 209 of file Manifest.h.

Constructor & Destructor Documentation

◆ ManifestCache()

ripple::ManifestCache::ManifestCache ( beast::Journal  j = beast::Journal(beast::Journal::getNullSink()))
explicit

Definition at line 223 of file Manifest.h.

Member Function Documentation

◆ getSigningKey()

PublicKey ripple::ManifestCache::getSigningKey ( PublicKey const &  pk) const

Returns master key's current signing key.

Parameters
pkMaster public key
Returns
pk if no known signing key from a manifest
Thread Safety

May be called concurrently

Definition at line 289 of file app/misc/impl/Manifest.cpp.

◆ getMasterKey()

PublicKey ripple::ManifestCache::getMasterKey ( PublicKey const &  pk) const

Returns ephemeral signing key's master public key.

Parameters
pkEphemeral signing public key
Returns
pk if signing key is not in a valid manifest
Thread Safety

May be called concurrently

Definition at line 301 of file app/misc/impl/Manifest.cpp.

◆ getSequence()

boost::optional< std::uint32_t > ripple::ManifestCache::getSequence ( PublicKey const &  pk) const

Returns master key's current manifest sequence.

Returns
sequence corresponding to Master public key if configured or boost::none otherwise

Definition at line 313 of file app/misc/impl/Manifest.cpp.

◆ getDomain()

boost::optional< std::string > ripple::ManifestCache::getDomain ( PublicKey const &  pk) const

Returns domain claimed by a given public key.

Returns
domain corresponding to Master public key if present, otherwise boost::none

Definition at line 325 of file app/misc/impl/Manifest.cpp.

◆ getManifest()

boost::optional< std::string > ripple::ManifestCache::getManifest ( PublicKey const &  pk) const

Returns mainfest corresponding to a given public key.

Returns
manifest corresponding to Master public key if present, otherwise boost::none

Definition at line 337 of file app/misc/impl/Manifest.cpp.

◆ revoked()

bool ripple::ManifestCache::revoked ( PublicKey const &  pk) const

Returns true if master key has been revoked in a manifest.

Parameters
pkMaster public key
Thread Safety

May be called concurrently

Definition at line 349 of file app/misc/impl/Manifest.cpp.

◆ applyManifest()

ManifestDisposition ripple::ManifestCache::applyManifest ( Manifest  m)

Add manifest to cache.

Parameters
mManifest to add
Returns
ManifestDisposition::accepted if successful, or stale or invalid otherwise
Thread Safety

May be called concurrently

Definition at line 361 of file app/misc/impl/Manifest.cpp.

◆ load() [1/2]

bool ripple::ManifestCache::load ( DatabaseCon dbCon,
std::string const &  dbTable,
std::string const &  configManifest,
std::vector< std::string > const &  configRevocation 
)

Populate manifest cache with manifests in database and config.

Parameters
dbConDatabase connection with dbTable
dbTableDatabase table
configManifestBase64 encoded manifest for local node's validator keys
configRevocationBase64 encoded validator key revocation from the config
Thread Safety

May be called concurrently

Definition at line 489 of file app/misc/impl/Manifest.cpp.

◆ load() [2/2]

void ripple::ManifestCache::load ( DatabaseCon dbCon,
std::string const &  dbTable 
)

Populate manifest cache with manifests in database.

Parameters
dbConDatabase connection with dbTable
dbTableDatabase table
Thread Safety

May be called concurrently

Definition at line 459 of file app/misc/impl/Manifest.cpp.

◆ save()

void ripple::ManifestCache::save ( DatabaseCon dbCon,
std::string const &  dbTable,
std::function< bool(PublicKey const &)>  isTrusted 
)

Save cached manifests to database.

Parameters
dbConDatabase connection with ValidatorManifests table
isTrustedFunction that returns true if manifest is trusted
Thread Safety

May be called concurrently

Definition at line 546 of file app/misc/impl/Manifest.cpp.

◆ for_each_manifest() [1/2]

template<class Function >
void ripple::ManifestCache::for_each_manifest ( Function &&  f) const

Invokes the callback once for every populated manifest.

Note
Undefined behavior results when calling ManifestCache members from within the callback
Parameters
fFunction called for each manifest
Thread Safety

May be called concurrently

Definition at line 369 of file Manifest.h.

◆ for_each_manifest() [2/2]

template<class PreFun , class EachFun >
void ripple::ManifestCache::for_each_manifest ( PreFun &&  pf,
EachFun &&  f 
) const

Invokes the callback once for every populated manifest.

Note
Undefined behavior results when calling ManifestCache members from within the callback
Parameters
pfPre-function called with the maximum number of times f will be called (useful for memory allocations)
fFunction called for each manifest
Thread Safety

May be called concurrently

Definition at line 395 of file Manifest.h.

Member Data Documentation

◆ j_

beast::Journal ripple::ManifestCache::j_
mutableprivate

Definition at line 212 of file Manifest.h.

◆ apply_mutex_

std::mutex ripple::ManifestCache::apply_mutex_
private

Definition at line 213 of file Manifest.h.

◆ read_mutex_

std::mutex ripple::ManifestCache::read_mutex_
mutableprivate

Definition at line 214 of file Manifest.h.

◆ map_

hash_map<PublicKey, Manifest> ripple::ManifestCache::map_
private

Active manifests stored by master public key.

Definition at line 217 of file Manifest.h.

◆ signingToMasterKeys_

hash_map<PublicKey, PublicKey> ripple::ManifestCache::signingToMasterKeys_
private

Master public keys stored by current ephemeral public key.

Definition at line 220 of file Manifest.h.