11 #include <boost/lexical_cast.hpp> 24 return "ABSTAIN";
break;
31 string strReturn =
"NONE";
38 strReturn =
"FUNDING";
47 strReturn =
"ENDORSED";
83 strReturn =
"CUSTOM1";
86 strReturn =
"CUSTOM2";
89 strReturn =
"CUSTOM3";
92 strReturn =
"CUSTOM4";
95 strReturn =
"CUSTOM5";
98 strReturn =
"CUSTOM6";
101 strReturn =
"CUSTOM7";
104 strReturn =
"CUSTOM8";
107 strReturn =
"CUSTOM9";
110 strReturn =
"CUSTOM10";
113 strReturn =
"CUSTOM11";
116 strReturn =
"CUSTOM12";
119 strReturn =
"CUSTOM13";
122 strReturn =
"CUSTOM14";
125 strReturn =
"CUSTOM15";
128 strReturn =
"CUSTOM16";
131 strReturn =
"CUSTOM17";
134 strReturn =
"CUSTOM18";
137 strReturn =
"CUSTOM19";
140 strReturn =
"CUSTOM20";
151 if(strVoteOutcome ==
"yes") {
154 else if(strVoteOutcome ==
"no") {
157 else if(strVoteOutcome ==
"abstain") {
166 if(strVoteSignal ==
"funding") {
169 else if(strVoteSignal ==
"valid") {
172 if(strVoteSignal ==
"delete") {
175 if(strVoteSignal ==
"endorsed") {
187 int i = boost::lexical_cast<
int>(strVoteSignal);
195 catch(std::exception
const & e)
197 std::ostringstream ostr;
198 ostr <<
"CGovernanceVote::ConvertVoteSignal: error : " << e.what() << std::endl;
219 nVoteSignal(eVoteSignalIn),
220 vinMasternode(outpointMasternodeIn),
221 nParentHash(nParentHashIn),
222 nVoteOutcome(eVoteOutcomeIn),
236 CPubKey pubKeyCollateralAddress;
237 CKey keyCollateralAddress;
239 std::string strError;
241 boost::lexical_cast<std::string>(
nVoteSignal) +
"|" + boost::lexical_cast<std::string>(
nVoteOutcome) +
"|" + boost::lexical_cast<std::string>(
nTime);
244 LogPrintf(
"CGovernanceVote::Sign -- SignMessage() failed\n");
249 LogPrintf(
"CGovernanceVote::Sign -- VerifyMessage() failed, error: %s\n", strError);
283 if(!fSignatureCheck)
return true;
285 std::string strError;
287 boost::lexical_cast<std::string>(
nVoteSignal) +
"|" + boost::lexical_cast<std::string>(
nVoteOutcome) +
"|" + boost::lexical_cast<std::string>(
nTime);
290 LogPrintf(
"CGovernanceVote::IsValid -- VerifyMessage() failed, error: %s\n", strError);
333 fResult = fResult && (vote1.
nTime < vote2.
nTime);
bool operator<(const CGovernanceVote &vote1, const CGovernanceVote &vote2)
static const int MIN_GOVERNANCE_PEER_PROTO_VERSION
static vote_signal_enum_t ConvertVoteSignal(std::string strVoteSignal)
void RelayInv(CInv &inv, const int minProtoVersion=MIN_PEER_PROTO_VERSION)
static vote_outcome_enum_t ConvertVoteOutcome(std::string strVoteOutcome)
static int LogPrint(const char *category, const char *format)
std::string ToString() const
bool GetMasternodeInfo(const COutPoint &outpoint, masternode_info_t &mnInfoRet)
static bool VerifyMessage(const CPubKey pubkey, const std::vector< unsigned char > &vchSig, const std::string strMessage, std::string &strErrorRet)
Verify the message signature, returns true if succcessful.
std::string ToString() const
bool operator==(const CGovernanceVote &vote1, const CGovernanceVote &vote2)
bool Sign(CKey &keyMasternode, CPubKey &pubKeyMasternode)
std::vector< unsigned char > vchSig
int64_t GetAdjustedTime()
static std::string ConvertOutcomeToString(vote_outcome_enum_t nOutcome)
static std::string ConvertSignalToString(vote_signal_enum_t nSignal)
static bool SignMessage(const std::string strMessage, std::vector< unsigned char > &vchSigRet, const CKey key)
Sign the message, returns true if successful.
void Relay(CConnman &connman) const
std::string ToStringShort() const
static const int MAX_SUPPORTED_VOTE_SIGNAL