6#ifndef ALT_INTEGRATION_VERIBLOCK_VALIDATION_STATE_HPP
7#define ALT_INTEGRATION_VERIBLOCK_VALIDATION_STATE_HPP
32 std::string toString()
const;
36 m_debug_message.clear();
40 bool Invalid(
const std::string &reject_reason,
41 const std::string &debug_message =
"");
52 bool Invalid(
const std::string &reject_reason,
53 const std::string &debug_message,
55 stack_trace.push_back(std::to_string(index));
56 return Invalid(reject_reason, debug_message);
59 bool Invalid(
const std::string &reject_reason,
size_t index) {
60 return Invalid(reject_reason,
"", index);
63 bool IsValid()
const {
return m_mode == MODE_VALID; }
64 bool IsInvalid()
const {
return m_mode == MODE_INVALID; }
65 std::string GetDebugMessage()
const {
return m_debug_message; }
67 std::vector<std::string> GetPathParts()
const;
69 std::string GetPath()
const;
76 std::string m_debug_message;
77 std::vector<std::string> stack_trace;
81template <
typename JsonValue>
83 auto obj = json::makeEmptyObject<JsonValue>();
85 if (acceptedToMempool !=
nullptr) {
86 json::putBoolKV(obj,
"accepted", *acceptedToMempool);
90 json::putStringKV(obj,
"state",
"valid");
92 }
else if (s.IsInvalid()) {
93 json::putStringKV(obj,
"state",
"invalid");
96 json::putStringKV(obj,
"code", s.GetPath());
97 json::putStringKV(obj,
"message", s.GetDebugMessage());
Class that is used for storing validation state.
bool Invalid(const std::string &reject_reason, const std::string &debug_message, size_t index)
Changes this ValidationState into "INVALID" mode.