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 
55  explicit Rules(std::unordered_set<uint256, beast::uhash<>> const& presets);
56 
57 private:
58  // Allow a friend function to construct Rules.
59  friend Rules
61  DigestAwareReadView const& ledger,
62  std::unordered_set<uint256, beast::uhash<>> const& presets);
63 
64  Rules(
65  std::unordered_set<uint256, beast::uhash<>> const& presets,
67  STVector256 const& amendments);
68 
69 public:
71  bool
72  enabled(uint256 const& feature) const;
73 
78  bool
79  operator==(Rules const&) const;
80 
81  bool
82  operator!=(Rules const& other) const;
83 };
84 
85 } // namespace ripple
86 #endif
ripple::Rules::enabled
bool enabled(uint256 const &feature) const
Returns true if a feature is enabled.
Definition: Rules.cpp:81
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::operator=
Rules & operator=(Rules const &)=default
ripple::Rules::operator!=
bool operator!=(Rules const &other) const
Definition: Rules.cpp:109
ripple::digest
static Hasher::result_type digest(void const *data, std::size_t size) noexcept
Definition: tokens.cpp:47
ripple::base_uint< 256 >
ripple::Rules::Impl
Definition: Rules.cpp:25
ripple::DigestAwareReadView
ReadView that associates keys with digests.
Definition: ReadView.h:339
ripple::Rules::makeRulesGivenLedger
friend Rules makeRulesGivenLedger(DigestAwareReadView const &ledger, std::unordered_set< uint256, beast::uhash<>> const &presets)
Definition: ReadView.cpp:69
ripple::Rules::operator==
bool operator==(Rules const &) const
Returns true if two rule sets are identical.
Definition: Rules.cpp:100
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<>