Skip to content

Commit

Permalink
Rename forks to flags.
Browse files Browse the repository at this point in the history
  • Loading branch information
evoskuil committed Mar 28, 2024
1 parent 9744ca1 commit b740bcf
Show file tree
Hide file tree
Showing 25 changed files with 294 additions and 293 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@
<ClInclude Include="..\..\..\..\include\bitcoin\system\chain\compact.hpp" />
<ClInclude Include="..\..\..\..\include\bitcoin\system\chain\context.hpp" />
<ClInclude Include="..\..\..\..\include\bitcoin\system\chain\enums\coverage.hpp" />
<ClInclude Include="..\..\..\..\include\bitcoin\system\chain\enums\forks.hpp" />
<ClInclude Include="..\..\..\..\include\bitcoin\system\chain\enums\flags.hpp" />
<ClInclude Include="..\..\..\..\include\bitcoin\system\chain\enums\magic_numbers.hpp" />
<ClInclude Include="..\..\..\..\include\bitcoin\system\chain\enums\numbers.hpp" />
<ClInclude Include="..\..\..\..\include\bitcoin\system\chain\enums\opcode.hpp" />
Expand Down Expand Up @@ -610,4 +610,4 @@
<ItemGroup>
<Natvis Include="..\..\debug.natvis" />
</ItemGroup>
</Project>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -635,7 +635,7 @@
<ClInclude Include="..\..\..\..\include\bitcoin\system\chain\enums\coverage.hpp">
<Filter>include\bitcoin\system\chain\enums</Filter>
</ClInclude>
<ClInclude Include="..\..\..\..\include\bitcoin\system\chain\enums\forks.hpp">
<ClInclude Include="..\..\..\..\include\bitcoin\system\chain\enums\flags.hpp">
<Filter>include\bitcoin\system\chain\enums</Filter>
</ClInclude>
<ClInclude Include="..\..\..\..\include\bitcoin\system\chain\enums\magic_numbers.hpp">
Expand Down Expand Up @@ -1604,4 +1604,4 @@
<Filter>resource</Filter>
</ResourceCompile>
</ItemGroup>
</Project>
</Project>
2 changes: 1 addition & 1 deletion include/bitcoin/system.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
#include <bitcoin/system/chain/transaction.hpp>
#include <bitcoin/system/chain/witness.hpp>
#include <bitcoin/system/chain/enums/coverage.hpp>
#include <bitcoin/system/chain/enums/forks.hpp>
#include <bitcoin/system/chain/enums/flags.hpp>
#include <bitcoin/system/chain/enums/magic_numbers.hpp>
#include <bitcoin/system/chain/enums/numbers.hpp>
#include <bitcoin/system/chain/enums/opcode.hpp>
Expand Down
2 changes: 1 addition & 1 deletion include/bitcoin/system/chain/chain.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
#include <bitcoin/system/chain/compact.hpp>
#include <bitcoin/system/chain/context.hpp>
#include <bitcoin/system/chain/enums/coverage.hpp>
#include <bitcoin/system/chain/enums/forks.hpp>
#include <bitcoin/system/chain/enums/flags.hpp>
#include <bitcoin/system/chain/enums/magic_numbers.hpp>
#include <bitcoin/system/chain/enums/numbers.hpp>
#include <bitcoin/system/chain/enums/opcode.hpp>
Expand Down
4 changes: 2 additions & 2 deletions include/bitcoin/system/chain/chain_state.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
#include <deque>
#include <bitcoin/system/chain/checkpoint.hpp>
#include <bitcoin/system/chain/context.hpp>
#include <bitcoin/system/chain/enums/forks.hpp>
#include <bitcoin/system/chain/enums/flags.hpp>
#include <bitcoin/system/define.hpp>
#include <bitcoin/system/hash/hash.hpp>
#include <bitcoin/system/math/math.hpp>
Expand All @@ -49,7 +49,7 @@ class BC_API chain_state
typedef std::shared_ptr<chain_state> ptr;
typedef struct { size_t count; size_t high; } range;

/// Chain state accepts configured forks and maps them onto active forks
/// Chain state accepts configured forks and maps them onto active flags
/// for the a given validaton context (i.e. block). These are exposed as
/// chain::chain_state.flags() and chain::context.flags. system::settings
/// settings are using within chain_state to compute context, but are never
Expand Down
6 changes: 3 additions & 3 deletions include/bitcoin/system/chain/context.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
#define LIBBITCOIN_SYSTEM_CHAIN_CONTEXT_HPP

#include <bitcoin/system/define.hpp>
#include <bitcoin/system/chain/enums/forks.hpp>
#include <bitcoin/system/chain/enums/flags.hpp>
#include <bitcoin/system/chain/enums/policy.hpp>

namespace libbitcoin {
Expand All @@ -30,8 +30,8 @@ namespace chain {
class BC_API context final
{
public:
/// Determine if the fork is active for this block.
bool is_enabled(chain::forks fork) const NOEXCEPT;
/// Determine if the flag is active for this block.
bool is_enabled(chain::flags flag) const NOEXCEPT;

/// Header context within chain.
uint32_t flags;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef LIBBITCOIN_SYSTEM_CHAIN_ENUMS_FORKS_HPP
#define LIBBITCOIN_SYSTEM_CHAIN_ENUMS_FORKS_HPP
#ifndef LIBBITCOIN_SYSTEM_CHAIN_ENUMS_FLAGS_HPP
#define LIBBITCOIN_SYSTEM_CHAIN_ENUMS_FLAGS_HPP

#include <bitcoin/system/define.hpp>
#include <bitcoin/system/math/math.hpp>
Expand All @@ -26,7 +26,7 @@ namespace libbitcoin {
namespace system {
namespace chain {

enum forks : uint32_t
enum flags : uint32_t
{
/// Rules start at satoshi v0.3.0.
/// Only satoshi-released hard forks, and enforced soft forks are included.
Expand Down Expand Up @@ -133,25 +133,25 @@ enum forks : uint32_t

/// Rules that use bip34-based activation.
bip34_activations =
forks::bip34_rule |
forks::bip65_rule |
forks::bip66_rule,
flags::bip34_rule |
flags::bip65_rule |
flags::bip66_rule,

/// Rules that use BIP9 bit 0 first time activation.
bip9_bit0_group =
forks::bip68_rule |
forks::bip112_rule |
forks::bip113_rule,
flags::bip68_rule |
flags::bip112_rule |
flags::bip113_rule,

/// Rules that use BIP9 bit 1 first time activation.
bip9_bit1_group =
forks::bip141_rule |
forks::bip143_rule |
forks::bip147_rule,
flags::bip141_rule |
flags::bip143_rule |
flags::bip147_rule,

/////// Rules that use BIP9 bit 4 first time activation.
////bip9_bit4_group =
//// forks::bip91_rule,
//// flags::bip91_rule,

/// Mask to set all rule bits.
all_rules = bit_all<uint32_t>
Expand Down
2 changes: 1 addition & 1 deletion include/bitcoin/system/chain/enums/policy.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ namespace libbitcoin {
namespace system {
namespace chain {

/// Analog to chain::forks but without impacting validation. These provide
/// Analog to chain::flags but without impacting validation. These provide
/// additional validation context, giving a node the option to reject an
/// unconfirmed transaction.
enum policy : uint32_t
Expand Down
2 changes: 1 addition & 1 deletion include/bitcoin/system/chain/operation.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@ class BC_API operation
void to_data(writer& sink) const NOEXCEPT;

// TODO: move to config serialization wrapper.
std::string to_string(uint32_t active_forks) const NOEXCEPT;
std::string to_string(uint32_t active_flags) const NOEXCEPT;

/// Properties.
/// -----------------------------------------------------------------------
Expand Down
15 changes: 8 additions & 7 deletions include/bitcoin/system/chain/script.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
#include <string>
#include <vector>
#include <bitcoin/system/chain/enums/coverage.hpp>
#include <bitcoin/system/chain/enums/forks.hpp>
#include <bitcoin/system/chain/enums/flags.hpp>
#include <bitcoin/system/chain/enums/magic_numbers.hpp>
#include <bitcoin/system/chain/enums/script_pattern.hpp>
#include <bitcoin/system/chain/enums/script_version.hpp>
Expand All @@ -51,10 +51,11 @@ class BC_API script
/// Utilities.
/// -----------------------------------------------------------------------

/// Determine if the fork is enabled in the active forks set.
static constexpr bool is_enabled(uint32_t active_forks, forks fork) NOEXCEPT
/// Determine if the flag is enabled in the active flags set.
static constexpr bool is_enabled(uint32_t active_flags,
chain::flags flag) NOEXCEPT
{
return to_bool(fork & active_forks);
return to_bool(flag & active_flags);
}

static inline bool is_push_only(const operations& ops) NOEXCEPT
Expand Down Expand Up @@ -471,7 +472,7 @@ class BC_API script
void to_data(writer& sink, bool prefix) const NOEXCEPT;

// TODO: move to config serialization wrapper.
std::string to_string(uint32_t active_forks) const NOEXCEPT;
std::string to_string(uint32_t active_flags) const NOEXCEPT;

/// Properties.
/// -----------------------------------------------------------------------
Expand All @@ -489,8 +490,8 @@ class BC_API script
/// -----------------------------------------------------------------------

/// Pattern optimizations.
bool is_pay_to_witness(uint32_t forks) const NOEXCEPT;
bool is_pay_to_script_hash(uint32_t forks) const NOEXCEPT;
bool is_pay_to_witness(uint32_t active_flags) const NOEXCEPT;
bool is_pay_to_script_hash(uint32_t active_flags) const NOEXCEPT;

/// Common pattern detection.
const data_chunk& witness_program() const NOEXCEPT;
Expand Down
Loading

0 comments on commit b740bcf

Please sign in to comment.