rippled
Loading...
Searching...
No Matches
Validations.h
1#pragma once
2
3#include <xrpld/consensus/LedgerTrie.h>
4
5#include <xrpl/basics/Log.h>
6#include <xrpl/basics/UnorderedContainers.h>
7#include <xrpl/basics/chrono.h>
8#include <xrpl/beast/container/aged_container_utility.h>
9#include <xrpl/beast/container/aged_unordered_map.h>
10#include <xrpl/protocol/PublicKey.h>
11
12#include <mutex>
13#include <optional>
14#include <type_traits>
15#include <utility>
16#include <vector>
17
18namespace xrpl {
19
71
78template <class Seq>
80{
81 using time_point = std::chrono::steady_clock::time_point;
82 Seq seq_{0};
84
85public:
98 bool
100 {
101 if (now > (when_ + p.validationSET_EXPIRES))
102 seq_ = Seq{0};
103 if (s <= seq_)
104 return false;
105 seq_ = s;
106 when_ = now;
107 return true;
108 }
109
110 Seq
111 largest() const
112 {
113 return seq_;
114 }
115};
116
128inline bool
130 ValidationParms const& p,
132 NetClock::time_point signTime,
133 NetClock::time_point seenTime)
134{
135 // Because this can be called on untrusted, possibly
136 // malicious validations, we do our math in a way
137 // that avoids any chance of overflowing or underflowing
138 // the signing time. All of the expressions below are
139 // promoted from unsigned 32 bit to signed 64 bit prior
140 // to computation.
141
142 return (signTime > (now - p.validationCURRENT_EARLY)) && (signTime < (now + p.validationCURRENT_WALL)) &&
143 ((seenTime == NetClock::time_point{}) || (seenTime < (now + p.validationCURRENT_LOCAL)));
144}
145
147enum class ValStatus {
149 current,
151 stale,
153 badSeq,
155 multiple,
158};
159
160inline std::string
162{
163 switch (m)
164 {
166 return "current";
167 case ValStatus::stale:
168 return "stale";
170 return "badSeq";
172 return "multiple";
174 return "conflicting";
175 default:
176 return "unknown";
177 }
178}
179
266template <class Adaptor>
268{
269 using Mutex = typename Adaptor::Mutex;
270 using Validation = typename Adaptor::Validation;
271 using Ledger = typename Adaptor::Ledger;
272 using ID = typename Ledger::ID;
273 using Seq = typename Ledger::Seq;
274 using NodeID = typename Validation::NodeID;
275 using NodeKey = typename Validation::NodeKey;
276
277 using WrappedValidationType = std::decay_t<std::invoke_result_t<decltype(&Validation::unwrap), Validation>>;
278
279 // Manages concurrent access to members
280 mutable Mutex mutex_;
281
282 // Validations from currently listed and trusted nodes (partial and full)
284
285 // Used to enforce the largest validation invariant for the local node
287
288 // Sequence of the largest validation received from each node
290
293
294 // Partial and full validations indexed by sequence
296
297 // A range [low_, high_) of validations to keep from expire
299 {
302 };
304
305 // Represents the ancestry of validated ledgers
307
308 // Last (validated) ledger successfully acquired. If in this map, it is
309 // accounted for in the trie.
311
312 // Set of ledgers being acquired from the network
314
315 // Parameters to determine validation staleness
317
318 // Adaptor instance
319 // Is NOT managed by the mutex_ above
320 Adaptor adaptor_;
321
322private:
323 // Remove support of a validated ledger
324 void
325 removeTrie(std::lock_guard<Mutex> const&, NodeID const& nodeID, Validation const& val)
326 {
327 {
328 auto it = acquiring_.find(std::make_pair(val.seq(), val.ledgerID()));
329 if (it != acquiring_.end())
330 {
331 it->second.erase(nodeID);
332 if (it->second.empty())
333 acquiring_.erase(it);
334 }
335 }
336 {
337 auto it = lastLedger_.find(nodeID);
338 if (it != lastLedger_.end() && it->second.id() == val.ledgerID())
339 {
340 trie_.remove(it->second);
341 lastLedger_.erase(nodeID);
342 }
343 }
344 }
345
346 // Check if any pending acquire ledger requests are complete
347 void
349 {
350 for (auto it = acquiring_.begin(); it != acquiring_.end();)
351 {
352 if (std::optional<Ledger> ledger = adaptor_.acquire(it->first.second))
353 {
354 for (NodeID const& nodeID : it->second)
355 updateTrie(lock, nodeID, *ledger);
356
357 it = acquiring_.erase(it);
358 }
359 else
360 ++it;
361 }
362 }
363
364 // Update the trie to reflect a new validated ledger
365 void
366 updateTrie(std::lock_guard<Mutex> const&, NodeID const& nodeID, Ledger ledger)
367 {
368 auto const [it, inserted] = lastLedger_.emplace(nodeID, ledger);
369 if (!inserted)
370 {
371 trie_.remove(it->second);
372 it->second = ledger;
373 }
374 trie_.insert(ledger);
375 }
376
390 void
392 std::lock_guard<Mutex> const& lock,
393 NodeID const& nodeID,
394 Validation const& val,
396 {
397 XRPL_ASSERT(val.trusted(), "xrpl::Validations::updateTrie : trusted input validation");
398
399 // Clear any prior acquiring ledger for this node
400 if (prior)
401 {
402 auto it = acquiring_.find(*prior);
403 if (it != acquiring_.end())
404 {
405 it->second.erase(nodeID);
406 if (it->second.empty())
407 acquiring_.erase(it);
408 }
409 }
410
411 checkAcquired(lock);
412
413 std::pair<Seq, ID> valPair{val.seq(), val.ledgerID()};
414 auto it = acquiring_.find(valPair);
415 if (it != acquiring_.end())
416 {
417 it->second.insert(nodeID);
418 }
419 else
420 {
421 if (std::optional<Ledger> ledger = adaptor_.acquire(val.ledgerID()))
422 updateTrie(lock, nodeID, *ledger);
423 else
424 acquiring_[valPair].insert(nodeID);
425 }
426 }
427
440 template <class F>
441 auto
443 {
444 // Call current to flush any stale validations
445 current(lock, [](auto) {}, [](auto, auto) {});
446 checkAcquired(lock);
447 return f(trie_);
448 }
449
466 template <class Pre, class F>
467 void
468 current(std::lock_guard<Mutex> const& lock, Pre&& pre, F&& f)
469 {
471 pre(current_.size());
472 auto it = current_.begin();
473 while (it != current_.end())
474 {
475 // Check for staleness
476 if (!isCurrent(parms_, t, it->second.signTime(), it->second.seenTime()))
477 {
478 removeTrie(lock, it->first, it->second);
479 it = current_.erase(it);
480 }
481 else
482 {
483 auto cit = typename decltype(current_)::const_iterator{it};
484 // contains a live record
485 f(cit->first, cit->second);
486 ++it;
487 }
488 }
489 }
490
503 template <class Pre, class F>
504 void
505 byLedger(std::lock_guard<Mutex> const&, ID const& ledgerID, Pre&& pre, F&& f)
506 {
507 auto it = byLedger_.find(ledgerID);
508 if (it != byLedger_.end())
509 {
510 // Update set time since it is being used
511 byLedger_.touch(it);
512 pre(it->second.size());
513 for (auto const& [key, val] : it->second)
514 f(key, val);
515 }
516 }
517
518public:
525 template <class... Ts>
530
533 Adaptor const&
534 adaptor() const
535 {
536 return adaptor_;
537 }
538
541 ValidationParms const&
542 parms() const
543 {
544 return parms_;
545 }
546
554 bool
556 {
558 return localSeqEnforcer_(byLedger_.clock().now(), s, parms_);
559 }
560
570 add(NodeID const& nodeID, Validation const& val)
571 {
572 if (!isCurrent(parms_, adaptor_.now(), val.signTime(), val.seenTime()))
573 return ValStatus::stale;
574
575 {
577
578 // Check that validation sequence is greater than any non-expired
579 // validations sequence from that validator; if it's not, perform
580 // additional work to detect Byzantine validations
581 auto const now = byLedger_.clock().now();
582
583 auto const [seqit, seqinserted] = bySequence_[val.seq()].emplace(nodeID, val);
584
585 if (!seqinserted)
586 {
587 // Check if the entry we're already tracking was signed
588 // long enough ago that we can disregard it.
589 auto const diff = std::max(seqit->second.signTime(), val.signTime()) -
590 std::min(seqit->second.signTime(), val.signTime());
591
592 if (diff > parms_.validationCURRENT_WALL && val.signTime() > seqit->second.signTime())
593 seqit->second = val;
594 }
595
596 // Enforce monotonically increasing sequences for validations
597 // by a given node, and run the active Byzantine detector:
598 if (auto& enf = seqEnforcers_[nodeID]; !enf(now, val.seq(), parms_))
599 {
600 // If the validation is for the same sequence as one we are
601 // tracking, check it closely:
602 if (seqit->second.seq() == val.seq())
603 {
604 // Two validations for the same sequence but for different
605 // ledgers. This could be the result of misconfiguration
606 // but it can also mean a Byzantine validator.
607 if (seqit->second.ledgerID() != val.ledgerID())
609
610 // Two validations for the same sequence and for the same
611 // ledger with different sign times. This could be the
612 // result of a misconfiguration but it can also mean a
613 // Byzantine validator.
614 if (seqit->second.signTime() != val.signTime())
616
617 // Two validations for the same sequence but with different
618 // cookies. This is probably accidental misconfiguration.
619 if (seqit->second.cookie() != val.cookie())
620 return ValStatus::multiple;
621 }
622
623 return ValStatus::badSeq;
624 }
625
626 byLedger_[val.ledgerID()].insert_or_assign(nodeID, val);
627
628 auto const [it, inserted] = current_.emplace(nodeID, val);
629 if (!inserted)
630 {
631 // Replace existing only if this one is newer
632 Validation& oldVal = it->second;
633 if (val.signTime() > oldVal.signTime())
634 {
635 std::pair<Seq, ID> old(oldVal.seq(), oldVal.ledgerID());
636 it->second = val;
637 if (val.trusted())
638 updateTrie(lock, nodeID, val, old);
639 }
640 else
641 return ValStatus::stale;
642 }
643 else if (val.trusted())
644 {
645 updateTrie(lock, nodeID, val, std::nullopt);
646 }
647 }
648
649 return ValStatus::current;
650 }
651
658 void
659 setSeqToKeep(Seq const& low, Seq const& high)
660 {
662 XRPL_ASSERT(low < high, "xrpl::Validations::setSeqToKeep : valid inputs");
663 toKeep_ = {low, high};
664 }
665
671 void
673 {
674 auto const start = std::chrono::steady_clock::now();
675 {
677 if (toKeep_)
678 {
679 // We only need to refresh the keep range when it's just about
680 // to expire. Track the next time we need to refresh.
681 static std::chrono::steady_clock::time_point refreshTime;
682 if (auto const now = byLedger_.clock().now(); refreshTime <= now)
683 {
684 // The next refresh time is shortly before the expiration
685 // time from now.
687
688 for (auto i = byLedger_.begin(); i != byLedger_.end(); ++i)
689 {
690 auto const& validationMap = i->second;
691 if (!validationMap.empty())
692 {
693 auto const seq = validationMap.begin()->second.seq();
694 if (toKeep_->low_ <= seq && seq < toKeep_->high_)
695 {
696 byLedger_.touch(i);
697 }
698 }
699 }
700
701 for (auto i = bySequence_.begin(); i != bySequence_.end(); ++i)
702 {
703 if (toKeep_->low_ <= i->first && i->first < toKeep_->high_)
704 {
705 bySequence_.touch(i);
706 }
707 }
708 }
709 }
710
713 }
714 JLOG(j.debug())
715 << "Validations sets sweep lock duration "
716 << std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::steady_clock::now() - start).count()
717 << "ms";
718 }
719
729 void
730 trustChanged(hash_set<NodeID> const& added, hash_set<NodeID> const& removed)
731 {
733
734 for (auto& [nodeId, validation] : current_)
735 {
736 if (added.find(nodeId) != added.end())
737 {
738 validation.setTrusted();
739 updateTrie(lock, nodeId, validation, std::nullopt);
740 }
741 else if (removed.find(nodeId) != removed.end())
742 {
743 validation.setUntrusted();
744 removeTrie(lock, nodeId, validation);
745 }
746 }
747
748 for (auto& [_, validationMap] : byLedger_)
749 {
750 (void)_;
751 for (auto& [nodeId, validation] : validationMap)
752 {
753 if (added.find(nodeId) != added.end())
754 {
755 validation.setTrusted();
756 }
757 else if (removed.find(nodeId) != removed.end())
758 {
759 validation.setUntrusted();
760 }
761 }
762 }
763 }
764
767 {
769 return trie_.getJson();
770 }
771
785 getPreferred(Ledger const& curr)
786 {
789 withTrie(lock, [this](LedgerTrie<Ledger>& trie) { return trie.getPreferred(localSeqEnforcer_.largest()); });
790 // No trusted validations to determine branch
791 if (!preferred)
792 {
793 // fall back to majority over acquiring ledgers
794 auto it = std::max_element(acquiring_.begin(), acquiring_.end(), [](auto const& a, auto const& b) {
795 std::pair<Seq, ID> const& aKey = a.first;
796 typename hash_set<NodeID>::size_type const& aSize = a.second.size();
797 std::pair<Seq, ID> const& bKey = b.first;
798 typename hash_set<NodeID>::size_type const& bSize = b.second.size();
799 // order by number of trusted peers validating that ledger
800 // break ties with ledger ID
801 return std::tie(aSize, aKey.second) < std::tie(bSize, bKey.second);
802 });
803 if (it != acquiring_.end())
804 return it->first;
805 return std::nullopt;
806 }
807
808 // If we are the parent of the preferred ledger, stick with our
809 // current ledger since we might be about to generate it
810 if (preferred->seq == curr.seq() + Seq{1} && preferred->ancestor(curr.seq()) == curr.id())
811 return std::make_pair(curr.seq(), curr.id());
812
813 // A ledger ahead of us is preferred regardless of whether it is
814 // a descendant of our working ledger or it is on a different chain
815 if (preferred->seq > curr.seq())
816 return std::make_pair(preferred->seq, preferred->id);
817
818 // Only switch to earlier or same sequence number
819 // if it is a different chain.
820 if (curr[preferred->seq] != preferred->id)
821 return std::make_pair(preferred->seq, preferred->id);
822
823 // Stick with current ledger
824 return std::make_pair(curr.seq(), curr.id());
825 }
826
836 ID
837 getPreferred(Ledger const& curr, Seq minValidSeq)
838 {
840 if (preferred && preferred->first >= minValidSeq)
841 return preferred->second;
842 return curr.id();
843 }
844
861 ID
862 getPreferredLCL(Ledger const& lcl, Seq minSeq, hash_map<ID, std::uint32_t> const& peerCounts)
863 {
865
866 // Trusted validations exist, but stick with local preferred ledger if
867 // preferred is in the past
868 if (preferred)
869 return (preferred->first >= minSeq) ? preferred->second : lcl.id();
870
871 // Otherwise, rely on peer ledgers
872 auto it = std::max_element(peerCounts.begin(), peerCounts.end(), [](auto& a, auto& b) {
873 // Prefer larger counts, then larger ids on ties
874 // (max_element expects this to return true if a < b)
875 return std::tie(a.second, a.first) < std::tie(b.second, b.first);
876 });
877
878 if (it != peerCounts.end())
879 return it->first;
880 return lcl.id();
881 }
882
895 getNodesAfter(Ledger const& ledger, ID const& ledgerID)
896 {
898
899 // Use trie if ledger is the right one
900 if (ledger.id() == ledgerID)
901 return withTrie(lock, [&ledger](LedgerTrie<Ledger>& trie) {
902 return trie.branchSupport(ledger) - trie.tipSupport(ledger);
903 });
904
905 // Count parent ledgers as fallback
906 return std::count_if(lastLedger_.begin(), lastLedger_.end(), [&ledgerID](auto const& it) {
907 auto const& curr = it.second;
908 return curr.seq() > Seq{0} && curr[curr.seq() - Seq{1}] == ledgerID;
909 });
910 }
911
918 {
920 std::lock_guard lock{mutex_};
921 current(
922 lock,
923 [&](std::size_t numValidations) { ret.reserve(numValidations); },
924 [&](NodeID const&, Validation const& v) {
925 if (v.trusted() && v.full())
926 ret.push_back(v.unwrap());
927 });
928 return ret;
929 }
930
935 auto
937 {
939 std::lock_guard lock{mutex_};
940 current(
941 lock,
942 [&](std::size_t numValidations) { ret.reserve(numValidations); },
943 [&](NodeID const& nid, Validation const&) { ret.insert(nid); });
944
945 return ret;
946 }
947
954 numTrustedForLedger(ID const& ledgerID)
955 {
956 std::size_t count = 0;
957 std::lock_guard lock{mutex_};
958 byLedger(
959 lock,
960 ledgerID,
961 [&](std::size_t) {}, // nothing to reserve
962 [&](NodeID const&, Validation const& v) {
963 if (v.trusted() && v.full())
964 ++count;
965 });
966 return count;
967 }
968
976 getTrustedForLedger(ID const& ledgerID, Seq const& seq)
977 {
979 std::lock_guard lock{mutex_};
980 byLedger(
981 lock,
982 ledgerID,
983 [&](std::size_t numValidations) { res.reserve(numValidations); },
984 [&](NodeID const&, Validation const& v) {
985 if (v.trusted() && v.full() && v.seq() == seq)
986 res.emplace_back(v.unwrap());
987 });
988
989 return res;
990 }
991
999 fees(ID const& ledgerID, std::uint32_t baseFee)
1000 {
1002 std::lock_guard lock{mutex_};
1003 byLedger(
1004 lock,
1005 ledgerID,
1006 [&](std::size_t numValidations) { res.reserve(numValidations); },
1007 [&](NodeID const&, Validation const& v) {
1008 if (v.trusted() && v.full())
1009 {
1010 std::optional<std::uint32_t> loadFee = v.loadFee();
1011 if (loadFee)
1012 res.push_back(*loadFee);
1013 else
1014 res.push_back(baseFee);
1015 }
1016 });
1017 return res;
1018 }
1019
1022 void
1024 {
1025 std::lock_guard lock{mutex_};
1026 current_.clear();
1027 }
1028
1045 laggards(Seq const seq, hash_set<NodeKey>& trustedKeys)
1046 {
1047 std::size_t laggards = 0;
1048
1049 current(
1050 std::lock_guard{mutex_},
1051 [](std::size_t) {},
1052 [&](NodeID const&, Validation const& v) {
1053 if (adaptor_.now() < v.seenTime() + parms_.validationFRESHNESS &&
1054 trustedKeys.find(v.key()) != trustedKeys.end())
1055 {
1056 trustedKeys.erase(v.key());
1057 if (seq > v.seq())
1058 ++laggards;
1059 }
1060 });
1061
1062 return laggards;
1063 }
1064
1067 {
1068 std::lock_guard lock{mutex_};
1069 return current_.size();
1070 }
1071
1074 {
1075 std::lock_guard lock{mutex_};
1076 return seqEnforcers_.size();
1077 }
1078
1081 {
1082 std::lock_guard lock{mutex_};
1083 return byLedger_.size();
1084 }
1085
1088 {
1089 std::lock_guard lock{mutex_};
1090 return bySequence_.size();
1091 }
1092};
1093
1094} // namespace xrpl
T begin(T... args)
Represents a JSON value.
Definition json_value.h:130
A generic endpoint for log messages.
Definition Journal.h:40
Stream debug() const
Definition Journal.h:300
Abstract interface to a clock.
Associative container where each element is also indexed by time.
Ancestry trie of ledgers.
Definition LedgerTrie.h:323
std::uint32_t tipSupport(Ledger const &ledger) const
Return count of tip support for the specific ledger.
Definition LedgerTrie.h:564
std::uint32_t branchSupport(Ledger const &ledger) const
Return the count of branch support for the specific ledger.
Definition LedgerTrie.h:578
std::optional< SpanTip< Ledger > > getPreferred(Seq const largestIssued) const
Return the preferred ledger ID.
Definition LedgerTrie.h:652
Enforce validation increasing sequence requirement.
Definition Validations.h:80
std::chrono::steady_clock::time_point time_point
Definition Validations.h:81
bool operator()(time_point now, Seq s, ValidationParms const &p)
Try advancing the largest observed validation ledger sequence.
Definition Validations.h:99
Seq largest() const
time_point when_
Definition Validations.h:83
Maintains current and recent ledger validations.
ID getPreferredLCL(Ledger const &lcl, Seq minSeq, hash_map< ID, std::uint32_t > const &peerCounts)
Determine the preferred last closed ledger for the next consensus round.
std::size_t getNodesAfter(Ledger const &ledger, ID const &ledgerID)
Count the number of current trusted validators working on a ledger after the specified one.
bool canValidateSeq(Seq const s)
Return whether the local node can issue a validation for the given sequence number.
beast::aged_unordered_map< ID, hash_map< NodeID, Validation >, std::chrono::steady_clock, beast::uhash<> > byLedger_
Validations from listed nodes, indexed by ledger id (partial and full)
LedgerTrie< Ledger > trie_
auto getCurrentNodeIDs() -> hash_set< NodeID >
Get the set of node ids associated with current validations.
typename Adaptor::Mutex Mutex
std::size_t numTrustedForLedger(ID const &ledgerID)
Count the number of trusted full validations for the given ledger.
std::vector< WrappedValidationType > getTrustedForLedger(ID const &ledgerID, Seq const &seq)
Get trusted full validations for a specific ledger.
void byLedger(std::lock_guard< Mutex > const &, ID const &ledgerID, Pre &&pre, F &&f)
Iterate the set of validations associated with a given ledger id.
ValStatus add(NodeID const &nodeID, Validation const &val)
Add a new validation.
void trustChanged(hash_set< NodeID > const &added, hash_set< NodeID > const &removed)
Update trust status of validations.
void checkAcquired(std::lock_guard< Mutex > const &lock)
ValidationParms const & parms() const
Return the validation timing parameters.
void current(std::lock_guard< Mutex > const &lock, Pre &&pre, F &&f)
Iterate current validations.
void removeTrie(std::lock_guard< Mutex > const &, NodeID const &nodeID, Validation const &val)
hash_map< NodeID, Validation > current_
hash_map< NodeID, SeqEnforcer< Seq > > seqEnforcers_
Adaptor const & adaptor() const
Return the adaptor instance.
hash_map< NodeID, Ledger > lastLedger_
auto withTrie(std::lock_guard< Mutex > const &lock, F &&f)
Use the trie for a calculation.
SeqEnforcer< Seq > localSeqEnforcer_
Json::Value getJsonTrie() const
std::size_t sizeOfCurrentCache() const
std::optional< std::pair< Seq, ID > > getPreferred(Ledger const &curr)
Return the sequence number and ID of the preferred working ledger.
typename Validation::NodeKey NodeKey
void flush()
Flush all current validations.
std::vector< WrappedValidationType > currentTrusted()
Get the currently trusted full validations.
void setSeqToKeep(Seq const &low, Seq const &high)
Set the range [low, high) of validations to keep from expire.
beast::aged_unordered_map< Seq, hash_map< NodeID, Validation >, std::chrono::steady_clock, beast::uhash<> > bySequence_
Validations(ValidationParms const &p, beast::abstract_clock< std::chrono::steady_clock > &c, Ts &&... ts)
Constructor.
ValidationParms const parms_
void updateTrie(std::lock_guard< Mutex > const &, NodeID const &nodeID, Ledger ledger)
std::size_t sizeOfByLedgerCache() const
typename Adaptor::Validation Validation
typename Ledger::Seq Seq
std::size_t sizeOfBySequenceCache() const
typename Ledger::ID ID
typename Validation::NodeID NodeID
typename Adaptor::Ledger Ledger
std::size_t sizeOfSeqEnforcersCache() const
std::optional< KeepRange > toKeep_
void expire(beast::Journal &j)
Expire old validation sets.
std::size_t laggards(Seq const seq, hash_set< NodeKey > &trustedKeys)
Return quantity of lagging proposers, and remove online proposers for purposes of evaluating whether ...
ID getPreferred(Ledger const &curr, Seq minValidSeq)
Get the ID of the preferred working ledger that exceeds a minimum valid ledger sequence number.
std::vector< std::uint32_t > fees(ID const &ledgerID, std::uint32_t baseFee)
Returns fees reported by trusted full validators in the given ledger.
void updateTrie(std::lock_guard< Mutex > const &lock, NodeID const &nodeID, Validation const &val, std::optional< std::pair< Seq, ID > > prior)
Process a new validation.
hash_map< std::pair< Seq, ID >, hash_set< NodeID > > acquiring_
T count_if(T... args)
T emplace_back(T... args)
T end(T... args)
T erase(T... args)
T find(T... args)
T insert(T... args)
T is_same_v
T make_pair(T... args)
T max_element(T... args)
T max(T... args)
T min(T... args)
std::enable_if< is_aged_container< AgedContainer >::value, std::size_t >::type expire(AgedContainer &c, std::chrono::duration< Rep, Period > const &age)
Expire aged container items past the specified age.
STL namespace.
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:5
bool isCurrent(ValidationParms const &p, NetClock::time_point now, NetClock::time_point signTime, NetClock::time_point seenTime)
Whether a validation is still current.
std::string to_string(base_uint< Bits, Tag > const &a)
Definition base_uint.h:597
ValStatus
Status of validation we received.
@ badSeq
A validation violates the increasing seq requirement.
@ stale
Not current or was older than current from this node.
@ current
This was a new validation and was added.
@ conflicting
Multiple validations by a validator for different ledgers.
@ multiple
Multiple validations by a validator for the same ledger.
Dir::const_iterator const_iterator
Definition Dir.cpp:5
@ validation
validation for signing
@ stale
Sequence is too old.
T push_back(T... args)
T reserve(T... args)
Timing parameters to control validation staleness and expiration.
Definition Validations.h:27
std::chrono::seconds validationFRESHNESS
How long we consider a validation fresh.
Definition Validations.h:69
std::chrono::seconds validationSET_EXPIRES
Duration a set of validations for a given ledger hash remain valid.
Definition Validations.h:59
std::chrono::seconds validationCURRENT_EARLY
Duration pre-close in which validations are acceptable.
Definition Validations.h:51
std::chrono::seconds validationCURRENT_LOCAL
Duration a validation remains current after first observed.
Definition Validations.h:44
std::chrono::seconds validationCURRENT_WALL
The number of seconds a validation remains current after its ledger's close time.
Definition Validations.h:36