@@ -52,26 +52,6 @@ const char* SYNCSTATUSCOUNT = "ssc";
5252const char * GETMNLIST = " dseg" ;
5353}; // namespace NetMsgType
5454
55- static const char * ppszTypeName[] = {
56- " ERROR" , // Should never occur
57- NetMsgType::TX,
58- NetMsgType::BLOCK,
59- " filtered block" , // Should never occur
60- " ix" , // deprecated
61- " txlvote" , // deprecated
62- NetMsgType::SPORK,
63- NetMsgType::MNWINNER,
64- " mnodescanerr" ,
65- NetMsgType::BUDGETVOTE,
66- NetMsgType::BUDGETPROPOSAL,
67- NetMsgType::FINALBUDGET,
68- NetMsgType::FINALBUDGETVOTE,
69- " mnq" ,
70- NetMsgType::MNBROADCAST,
71- NetMsgType::MNPING,
72- " dstx" // deprecated
73- };
74-
7555/* * All known message types. Keep this in the same order as the list of
7656 * messages above and in protocol.h.
7757 */
@@ -207,25 +187,36 @@ bool operator<(const CInv& a, const CInv& b)
207187 return (a.type < b.type || (a.type == b.type && a.hash < b.hash ));
208188}
209189
210- bool CInv::IsKnownType () const
211- {
212- return (type >= 1 && type < (int )ARRAYLEN (ppszTypeName));
213- }
214-
215190bool CInv::IsMasterNodeType () const {
216191 return type > 2 ;
217192}
218193
219- const char * CInv::GetCommand () const
194+ std::string CInv::GetCommand () const
220195{
221- if (!IsKnownType ()) {
222- LogPrint (BCLog::NET, " CInv::GetCommand() : type=%d unknown type" , type);
223- return " UNKNOWN" ;
196+ std::string cmd;
197+ switch (type) {
198+ case MSG_TX: return cmd.append (NetMsgType::TX);
199+ case MSG_BLOCK: return cmd.append (NetMsgType::BLOCK);
200+ case MSG_FILTERED_BLOCK: return cmd.append (NetMsgType::MERKLEBLOCK);
201+ case MSG_TXLOCK_REQUEST: return cmd.append (" ix" ); // Deprecated
202+ case MSG_TXLOCK_VOTE: return cmd.append (" txlvote" ); // Deprecated
203+ case MSG_SPORK: return cmd.append (NetMsgType::SPORK);
204+ case MSG_MASTERNODE_WINNER: return cmd.append (NetMsgType::MNWINNER);
205+ case MSG_MASTERNODE_SCANNING_ERROR: return cmd.append (" mnodescanerr" ); // Deprecated
206+ case MSG_BUDGET_VOTE: return cmd.append (NetMsgType::BUDGETVOTE);
207+ case MSG_BUDGET_PROPOSAL: return cmd.append (NetMsgType::BUDGETPROPOSAL);
208+ case MSG_BUDGET_FINALIZED: return cmd.append (NetMsgType::FINALBUDGET);
209+ case MSG_BUDGET_FINALIZED_VOTE: return cmd.append (NetMsgType::FINALBUDGETVOTE);
210+ case MSG_MASTERNODE_QUORUM: return cmd.append (" mnq" ); // Unused
211+ case MSG_MASTERNODE_ANNOUNCE: return cmd.append (NetMsgType::MNBROADCAST);
212+ case MSG_MASTERNODE_PING: return cmd.append (NetMsgType::MNPING);
213+ case MSG_DSTX: return cmd.append (" dstx" ); // Deprecated
214+ default :
215+ throw std::out_of_range (strprintf (" %s: type=%d unknown type" , __func__, type));
224216 }
225-
226- return ppszTypeName[type];
227217}
228218
219+
229220std::string CInv::ToString () const
230221{
231222 return strprintf (" %s %s" , GetCommand (), hash.ToString ());
0 commit comments