rippled
Rules.h
1 //------------------------------------------------------------------------------
2 /*
3  This file is part of rippled: https://github.com/ripple/rippled
4  Copyright (c) 2012, 2013 Ripple Labs Inc.
5 
6  Permission to use, copy, modify, and/or distribute this software for any
7  purpose with or without fee is hereby granted, provided that the above
8  copyright notice and this permission notice appear in all copies.
9 
10  THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11  WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12  MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13  ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14  WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15  ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16  OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 */
18 //==============================================================================
19 
20 #ifndef RIPPLE_LEDGER_RULES_H_INCLUDED
21 #define RIPPLE_LEDGER_RULES_H_INCLUDED
22 
23 #include <ripple/basics/base_uint.h>
24 #include <ripple/beast/hash/uhash.h>
25 #include <ripple/protocol/STVector256.h>
26 #include <unordered_set>
27 
28 namespace ripple {
29 
30 class DigestAwareReadView;
31 
33 class Rules
34 {
35 private:
36  class Impl;
37 
38  // Carrying impl by shared_ptr makes Rules comparatively cheap to pass
39  // by value.
41 
42 public:
43  Rules(Rules const&) = default;
44 
45  Rules&
46  operator=(Rules const&) = default;
47 
48  Rules() = delete;
49 
56 
57 private:
58  // Allow a friend function to construct Rules.
59  friend Rules
61  DigestAwareReadView const& ledger,
62  Rules const& current);
63 
64  friend Rules
66  DigestAwareReadView const& ledger,
68 
69  Rules(
72  STVector256 const& amendments);
73 
75  presets() const;
76 
77 public:
79  bool
80  enabled(uint256 const& feature) const;
81 
86  bool
87  operator==(Rules const&) const;
88 
89  bool
90  operator!=(Rules const& other) const;
91 };
92 
93 } // namespace ripple
94 #endif
ripple::Rules::presets
std::unordered_set< uint256, beast::uhash<> > const & presets() const
Definition: Rules.cpp:88
ripple::Rules::enabled
bool enabled(uint256 const &feature) const
Returns true if a feature is enabled.
Definition: Rules.cpp:94
std::shared_ptr
STL class.
ripple::Rules::Rules
Rules()=delete
ripple::Rules::impl_
std::shared_ptr< Impl const > impl_
Definition: Rules.h:36
unordered_set
ripple::Rules::makeRulesGivenLedger
friend Rules makeRulesGivenLedger(DigestAwareReadView const &ledger, Rules const &current)
Definition: ReadView.cpp:69
ripple::Rules::operator=
Rules & operator=(Rules const &)=default
ripple::Rules::operator!=
bool operator!=(Rules const &other) const
Definition: Rules.cpp:122
ripple::digest
static Hasher::result_type digest(void const *data, std::size_t size) noexcept
Definition: tokens.cpp:47
ripple::base_uint
Integers of any length that is a multiple of 32-bits.
Definition: base_uint.h:82
ripple::Rules::Impl
Definition: Rules.cpp:25
ripple::DigestAwareReadView
ReadView that associates keys with digests.
Definition: ReadView.h:329
ripple::Rules::operator==
bool operator==(Rules const &) const
Returns true if two rule sets are identical.
Definition: Rules.cpp:113
ripple
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition: RCLCensorshipDetector.h:29
ripple::STVector256
Definition: STVector256.h:29
ripple::Rules
Rules controlling protocol behavior.
Definition: Rules.h:33
std::optional
beast::uhash<>