CatapultServer  v0.5.0.1 (Elephant)
ChainComparisonCode.h
Go to the documentation of this file.
1 
21 #pragma once
22 #include <iosfwd>
23 #include <stdint.h>
24 
25 namespace catapult { namespace chain {
26 
28  constexpr uint32_t Remote_Is_Out_Of_Sync_Flag = 0x40000000;
29 
31  constexpr uint32_t Remote_Is_Evil_Flag = 0x80000000;
32 
33 #define CHAIN_COMPARISON_CODE_LIST \
34  /* Remote and local nodes reported equal chain scores. */ \
35  ENUM_VALUE(Remote_Reported_Equal_Chain_Score, 1) \
36  \
37  /* Remote node reported a lower chain score than the local node. */ \
38  ENUM_VALUE(Remote_Reported_Lower_Chain_Score, 2) \
39  \
40  /* Local node has a chain score of zero indicating that it is not completely initialized. */ \
41  ENUM_VALUE(Local_Chain_Score_Zero, 3) \
42  \
43  /* Remote node is too far behind the local node. */ \
44  ENUM_VALUE(Remote_Is_Too_Far_Behind, Remote_Is_Out_Of_Sync_Flag | 1) \
45  \
46  /* Remote node is not in sync with the local node. */ \
47  ENUM_VALUE(Remote_Is_Not_Synced, Remote_Is_Out_Of_Sync_Flag | 2) \
48  \
49  /* Remote node returned too many hashes. */ \
50  ENUM_VALUE(Remote_Returned_Too_Many_Hashes, Remote_Is_Evil_Flag | 1) \
51  \
52  /* Remote node is on a fork. */ \
53  ENUM_VALUE(Remote_Is_Forked, Remote_Is_Evil_Flag | 2) \
54  \
55  /* Remote node lied about having a higher chain score. */ \
56  ENUM_VALUE(Remote_Lied_About_Chain_Score, Remote_Is_Evil_Flag | 3)
57 
58 #define ENUM_VALUE(LABEL, VALUE) LABEL = VALUE,
59  enum class ChainComparisonCode : uint32_t {
62  };
63 #undef ENUM_VALUE
64 
66  std::ostream& operator<<(std::ostream& out, ChainComparisonCode value);
67 
70 
73 }}
MacroBasedEnum.h
catapult::chain::ChainComparisonCode::CHAIN_COMPARISON_CODE_LIST
ChainComparisonCode.h
catapult::utils::to_underlying_type
constexpr std::underlying_type_t< TEnum > to_underlying_type(TEnum value)
Converts a strongly typed enumeration value to its underlying integral value.
Definition: Casting.h:37
catapult::chain::IsRemoteEvil
bool IsRemoteEvil(ChainComparisonCode code)
Gets a value indicating whether or not code indicates that the remote node is evil.
Definition: ChainComparisonCode.cpp:38
catapult::chain::Remote_Is_Evil_Flag
constexpr uint32_t Remote_Is_Evil_Flag
Chain comparison code flag that is set if the code indicates an evil remote node.
Definition: ChainComparisonCode.h:31
catapult::chain::Remote_Is_Out_Of_Sync_Flag
constexpr uint32_t Remote_Is_Out_Of_Sync_Flag
Chain comparison code flag that is set if the code indicates an out of sync remote node.
Definition: ChainComparisonCode.h:28
MacroBasedEnumIncludes.h
catapult::chain::ChainComparisonCode
ChainComparisonCode
Possible chain comparison end states.
Definition: ChainComparisonCode.h:60
catapult
Definition: AddressExtractionExtension.cpp:28
catapult::chain::IsRemoteOutOfSync
bool IsRemoteOutOfSync(ChainComparisonCode code)
Gets a value indicating whether or not code indicates that the remote node is out of sync.
Definition: ChainComparisonCode.cpp:34
catapult::chain::operator<<
std::ostream & operator<<(std::ostream &out, ChainComparisonCode value)
Insertion operator for outputting value to out.