|
xrpld
|
Remembers manifests with the highest sequence number. More...
#include <Manifest.h>

Public Member Functions | |
| ManifestCache (beast::Journal j=beast::Journal(beast::Journal::getNullSink()), std::size_t maxUntrustedCount=kMaxUntrustedCount) | |
| std::uint32_t | sequence () const |
| A monotonically increasing number used to detect new manifests. | |
| std::optional< PublicKey > | getSigningKey (PublicKey const &pk) const |
| Returns master key's current signing key. | |
| PublicKey | getMasterKey (PublicKey const &pk) const |
| Returns ephemeral signing key's master public key. | |
| std::optional< std::uint32_t > | getSequence (PublicKey const &pk) const |
| Returns master key's current manifest sequence. | |
| std::optional< std::string > | getDomain (PublicKey const &pk) const |
| Returns domain claimed by a given public key. | |
| std::optional< std::string > | getManifest (PublicKey const &pk) const |
| Returns manifest corresponding to a given public key. | |
| bool | revoked (PublicKey const &pk) const |
| Returns true if master key has been revoked in a manifest. | |
| ManifestDisposition | applyManifest (Manifest m, ManifestRateLimitCapPolicy cap) |
| Add manifest to cache. | |
| void | promoteToTrusted (PublicKey const &pk) |
| Stop counting a master key against the untrusted cap. | |
| 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. | |
| void | load (DatabaseCon &dbCon, std::string const &dbTable) |
| Populate manifest cache with manifests in database. | |
| void | save (DatabaseCon &dbCon, std::string const &dbTable, std::function< bool(PublicKey const &)> const &isTrusted) |
| Save cached manifests to database. | |
| template<class Function> | |
| void | forEachManifest (Function &&f) const |
| Invokes the callback once for every populated manifest. | |
| template<class PreFun, class EachFun> | |
| void | forEachManifest (PreFun &&pf, EachFun &&f) const |
| Invokes the callback once for every populated manifest. | |
Private Attributes | |
| beast::Journal | j_ |
| std::shared_mutex | mutex_ |
| hash_map< PublicKey, Manifest > | map_ |
| Active manifests stored by master public key. | |
| hash_map< PublicKey, PublicKey > | signingToMasterKeys_ |
| Master public keys stored by current ephemeral public key. | |
| std::atomic< std::uint32_t > | seq_ {0} |
| hash_set< PublicKey > | untrustedKeys_ |
| Master keys of cached manifests for validators this node does not list. | |
| std::size_t const | maxUntrustedCount_ |
| Maximum number of untrusted master keys kept in the cache. | |
| std::atomic< std::uint64_t > | untrustedRejectCount_ {0} |
| Running count of manifests rejected because the untrusted cap was full. | |
Static Private Attributes | |
| static constexpr std::uint64_t | kUntrustedRejectCount = 10000 |
| Number of cap rejections between summary warnings. | |
Remembers manifests with the highest sequence number.
Definition at line 373 of file Manifest.h.
|
explicit |
| j | Journal for logging. |
| maxUntrustedCount | Untrusted master keys to keep. Pass the configured value; defaults to kMaxUntrustedCount. Taken as a parameter because this module cannot depend on the config. |
Definition at line 432 of file Manifest.h.
| std::uint32_t xrpl::ManifestCache::sequence | ( | ) | const |
A monotonically increasing number used to detect new manifests.
Definition at line 443 of file Manifest.h.
| std::optional< PublicKey > xrpl::ManifestCache::getSigningKey | ( | PublicKey const & | pk | ) | const |
Returns master key's current signing key.
| pk | Master public key |
May be called concurrently
Definition at line 312 of file libxrpl/server/Manifest.cpp.
Returns ephemeral signing key's master public key.
| pk | Ephemeral signing public key |
May be called concurrently
Definition at line 324 of file libxrpl/server/Manifest.cpp.
| std::optional< std::uint32_t > xrpl::ManifestCache::getSequence | ( | PublicKey const & | pk | ) | const |
Returns master key's current manifest sequence.
Definition at line 335 of file libxrpl/server/Manifest.cpp.
| std::optional< std::string > xrpl::ManifestCache::getDomain | ( | PublicKey const & | pk | ) | const |
Returns domain claimed by a given public key.
Definition at line 347 of file libxrpl/server/Manifest.cpp.
| std::optional< std::string > xrpl::ManifestCache::getManifest | ( | PublicKey const & | pk | ) | const |
Returns manifest corresponding to a given public key.
Definition at line 359 of file libxrpl/server/Manifest.cpp.
| bool xrpl::ManifestCache::revoked | ( | PublicKey const & | pk | ) | const |
Returns true if master key has been revoked in a manifest.
| pk | Master public key |
May be called concurrently
Definition at line 371 of file libxrpl/server/Manifest.cpp.
| ManifestDisposition xrpl::ManifestCache::applyManifest | ( | Manifest | m, |
| ManifestRateLimitCapPolicy | cap ) |
Add manifest to cache.
A brand-new unlisted key is rejected once the untrusted cap is full; updates to a cached key and Uncapped manifests bypass the cap. The caller decides cap before calling so the cache lock is not held while consulting the validator list, which would risk a lock-ordering deadlock.
| m | Manifest to add |
| cap | Uncapped skips the untrusted cap; use it for keys that are listed, configured, or loaded from the DB. Note Uncapped does not assert the key is currently trusted (a DB entry may predate a de-listing). Callers must state this explicitly so a manifest is never left uncapped by omission. |
May be called concurrently
Definition at line 383 of file libxrpl/server/Manifest.cpp.
| void xrpl::ManifestCache::promoteToTrusted | ( | PublicKey const & | pk | ) |
Stop counting a master key against the untrusted cap.
Called when a cached untrusted key becomes listed, freeing its slot. Idempotent and a no-op for keys that were never counted.
| pk | Master public key that is now listed/trusted |
May be called concurrently
Definition at line 596 of file libxrpl/server/Manifest.cpp.
| bool xrpl::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.
| dbCon | Database connection with dbTable |
| dbTable | Database table |
| configManifest | Base64 encoded manifest for local node's validator keys |
| configRevocation | Base64 encoded validator key revocation from the config |
May be called concurrently
Definition at line 613 of file libxrpl/server/Manifest.cpp.
| void xrpl::ManifestCache::load | ( | DatabaseCon & | dbCon, |
| std::string const & | dbTable ) |
Populate manifest cache with manifests in database.
| dbCon | Database connection with dbTable |
| dbTable | Database table |
May be called concurrently
Definition at line 606 of file libxrpl/server/Manifest.cpp.
| void xrpl::ManifestCache::save | ( | DatabaseCon & | dbCon, |
| std::string const & | dbTable, | ||
| std::function< bool(PublicKey const &)> const & | isTrusted ) |
Save cached manifests to database.
| dbCon | Database connection with ValidatorManifests table |
| isTrusted | Function that returns true if manifest is trusted |
May be called concurrently
Definition at line 671 of file libxrpl/server/Manifest.cpp.
| void xrpl::ManifestCache::forEachManifest | ( | Function && | f | ) | const |
Invokes the callback once for every populated manifest.
| f | Function called for each manifest |
May be called concurrently
Definition at line 628 of file Manifest.h.
| void xrpl::ManifestCache::forEachManifest | ( | PreFun && | pf, |
| EachFun && | f ) const |
Invokes the callback once for every populated manifest.
| pf | Pre-function called with the maximum number of times f will be called (useful for memory allocations) |
| f | Function called for each manifest |
May be called concurrently
Definition at line 657 of file Manifest.h.
|
private |
Definition at line 376 of file Manifest.h.
|
mutableprivate |
Definition at line 377 of file Manifest.h.
Active manifests stored by master public key.
Definition at line 382 of file Manifest.h.
Master public keys stored by current ephemeral public key.
Definition at line 387 of file Manifest.h.
|
private |
Definition at line 389 of file Manifest.h.
Master keys of cached manifests for validators this node does not list.
One entry per capped key in map_; its size enforces the cap below. A key is added when first cached under Capped and removed when it becomes listed (see promoteToTrusted) or an Uncapped update arrives, never re-added on de-listing. Uncapped keys are not tracked here.
Definition at line 399 of file Manifest.h.
|
private |
Maximum number of untrusted master keys kept in the cache.
Once reached, a manifest for a brand-new unlisted key is rejected. Set from the config, defaulting to kMaxUntrustedCount.
Definition at line 407 of file Manifest.h.
|
private |
Running count of manifests rejected because the untrusted cap was full.
Drives throttled logging (see kUntrustedRejectCount). Atomic because applyManifest may run concurrently.
Definition at line 415 of file Manifest.h.
|
staticconstexprprivate |
Number of cap rejections between summary warnings.
Definition at line 422 of file Manifest.h.