CCF
Loading...
Searching...
No Matches
proposals.h
Go to the documentation of this file.
1// Copyright (c) Microsoft Corporation. All rights reserved.
2// Licensed under the Apache 2.0 License.
3#pragma once
4
5#include "ccf/ds/json.h"
6#include "ccf/service/map.h"
7
8#include <unordered_map>
9#include <vector>
10
11namespace ccf
12{
18 enum class ProposalState
19 {
20 OPEN, //< Proposal is active and can be voted on
21 ACCEPTED, //< Proposal passed a successful vote and was enacted
22 WITHDRAWN, //< Proposal was removed by proposing member, will never be
23 // enacted
24 REJECTED, //< Proposal was rejected by vote, will never be enacted
25 FAILED, //< Proposal passed a successful vote, but its proposed actions
26 // failed, will never be enacted
27 DROPPED, //< Proposal was open when its semantics were potentially changed
28 // (code or constitution were modified), so it was automatically
29 // invalidated and dropped
30 };
33 {{ProposalState::OPEN, "Open"},
34 {ProposalState::ACCEPTED, "Accepted"},
35 {ProposalState::WITHDRAWN, "Withdrawn"},
36 {ProposalState::REJECTED, "Rejected"},
37 {ProposalState::FAILED, "Failed"},
38 {ProposalState::DROPPED, "Dropped"}});
39
40 using ProposalId = std::string;
41}
42
43FMT_BEGIN_NAMESPACE
44template <>
45struct formatter<ccf::ProposalState>
46{
47 template <typename ParseContext>
48 constexpr auto parse(ParseContext& ctx)
49 {
50 return ctx.begin();
51 }
52
53 template <typename FormatContext>
54 auto format(const ccf::ProposalState& state, FormatContext& ctx) const
55 -> decltype(ctx.out())
56 {
57 switch (state)
58 {
60 {
61 return format_to(ctx.out(), "open");
62 }
64 {
65 return format_to(ctx.out(), "accepted");
66 }
68 {
69 return format_to(ctx.out(), "withdrawn");
70 }
72 {
73 return format_to(ctx.out(), "rejected");
74 }
76 {
77 return format_to(ctx.out(), "dropped");
78 }
79 default:
80 {
81 return format_to(ctx.out(), "UNKNOWN");
82 }
83 }
84 }
85};
86FMT_END_NAMESPACE
#define DECLARE_JSON_ENUM(TYPE,...)
Definition json.h:837
Definition app_interface.h:14
ProposalState
Definition proposals.h:19
std::string ProposalId
Definition proposals.h:40
constexpr auto parse(ParseContext &ctx)
Definition proposals.h:48
auto format(const ccf::ProposalState &state, FormatContext &ctx) const -> decltype(ctx.out())
Definition proposals.h:54