Dash Core  0.12.2.1
P2P Digital Currency
governance-classes.h
Go to the documentation of this file.
1 // Copyright (c) 2014-2017 The Dash Core developers
2 
3 /*
4  * FIELDS AND CLASSIFICATION
5  * --------------------
6  *
7  * -- fields can be updated by the network dynamically (adding a company type, etc)
8  * -- fields can be voted on, leveling them up/down
9  * -- levels determine pay in DO/DAO company types
10  *
11  * FIELDS
12  * =========================
13  *
14  * network-type mainnet, testnet, regtest
15  * actor-type group, user, dao, company, committee, foundation
16  * group-type core, noncore
17  * dao-type none
18  * company-type us.llc, us.501c3, us.501c6, us.inc, etc
19  * committee-type science, technology, economics
20  * foundation-type us.501c6, us.501c3
21  * contract-type blockchain/internal, external/contractor
22  * proposal-type explicit, governance, wikiamend, generic, black
23  *
24  * lvl 1,2,3,4.. roman
25  * status ok, error, active-removal
26  * proposal-rights explicit, explicit_generic, all
27  * contract-rights internal, external
28  * status-error missing-documentation, doa, report-outstanding
29  * milestone-status research, hiring, ongoing, complete, failure, overdue, error //programmatic workflow?
30  * milestone-status-error mia, option2, option3
31  * network-status ok, error
32  * network-error none, fork-detected, debug, full-blocks, network-outage, spam
33  * foundation-type maintainance, r&d, awareness, bridge(legacy), philanthropic, legal
34  * committee-type business, sciencific_advisory, research
35  * global-type-variable switch, int, string, enum // enum should be defined by another category
36  * category-type primary, secondary, tertiary, quaternary, quinary, senary, septenary, octonary
37  * contract-status ok, error
38  * cantract-status-error none, error1, error2
39  * committee-type research, business_advisory, economic_advisory
40  *
41  * // note: How enums work
42  * enum-type one, two, three //defined in code, or the defintion could be packed ino this field
43  *
44  * CLASSES
45  * =========================
46  *
47  * // network
48  * CDashNetwork lvl, network-type, network-status, network-error, milestone-status*
49  * CCategory lvl, category-type, status, status-error
50  * CNetworkGlobalVariable lvl, global-type, status, status-error
51  * // base: actor
52  * CGroup lvl, actor-type, status, status-error, group-type
53  * CUser lvl, actor-type, status, status-error, user-type, contract-status, contract-status-error
54  * CDAO lvl, actor-type, status, status-error, dao-type
55  * CCompany lvl, actor-type, secondary-type, ternary-type, status, status-error
56  * CCommittee lvl, actor-type, status, status-error, committee-type ov
57  * CFoundation lvl, actor-type, status, status-error, foundation-type ov
58  * // base: project manangement
59  * CProposal lvl, proposal-type, status, status-error
60  * CContract lvl, contract-type, status, status-error, proposal-rights, contract-rights
61  * CProject lvl, project-type, status, status-error
62  * CProjectReport lvl, report-type, status, status-error
63  * CProjectMilestone lvl, milestone-type, status, status-error, milestone-status, milestone-status-error, ov
64  * CValueOverride lvl, vo-type, status, status-error
65 */
66 
67 
68 
69 /*
70  * CLASS INHERITANCE
71  * ============================================================
72  *
73  * -- Each of the implementable classes use their own serializers
74  * -- Each class is responsible for it's own unique values
75  * -- Most of the values in these classes can be overriden
76  *
77  * CGovernanceNode (base)
78  *
79  * TREE STRUCTURE
80  * ===========================================
81  *
82  * DASH NETWORK (ROOT)
83  * -> NETWORK GLOBOLS
84  * -> SWITCHES, SETTINGS
85  * -> CATEGORIES
86  * -> CATEGORY (DAO)
87  * -> CATEGORIES ()
88  * -> CATEGORY (CONTRACT)
89  * -> CATEGORIES (INTERNAL, EXTERNAL, ...)
90  * -> GROUPS
91  * -> GROUP 1
92  * -> USER : ENDUSER
93  * -> COMPANIES
94  * -> DAO
95  * -> COMPANY, COMMITTEE, FOUNDATION, ..
96  * -> GROUP1 (CORE)
97  * - USER : EVAN DUFFIELD
98  * -> CONTRACT1 (INTERNAL CONTRACT)
99  * -> PROJECT1
100  * -> PROJECT1
101  * -> CONTRACT2 (EXTERNAL CONTRACT)
102  * -> PROPOSAL (GENERIC FUNDING)
103  * -> VO (OUTPUT VALUE == 3.23) // NETWORK OVERRIDE
104  * -> REPORT1
105  * -> REPORT2
106  * -> REPORT3
107  * -> MILESTONE1
108  * -> MILESTONE2
109  * -> OV (STATUS=OVERDUE)
110 **/
111 
112 
113 class CGovernanceObject : public CGovernanceNode
114 {
115 private:
116  // some minimal caching is supported here
117  int nLevel;
118  std::string strCategory;
119 
120  // Current OBJECT STATUS (see http://govman.dash.org/index.php/Documentation_:_Status_Field)
122  std::string strStatusMessage;
123 
124  // minimal caching
126 
127 public:
128 
129  virtual uint256 GetHash() = 0;
130 };
131 
132 // // root node
134 {
135 private:
136  std::string strName;
137  std::string strURL;
138 
139 
140 public:
142  {
143  strName = objIn["name"].get_str();
144  strURL = objIn["name"].get_str();
145 
146  // we should pop these off one by one and check if the objIn.size() == 0
147  }
148 
151  ss << strName;
152  ss << strURL;
153  ss << nTime;
154  ss << vecSig;
155  ss << nGovernanceType;
156  uint256 h1 = ss.GetHash();
157 
158  return h1;
159  }
160 
162 
163  template <typename Stream, typename Operation>
164  inline void SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) {
165  // TODO : For testnet version bump
166  READWRITE(nGovernanceType);
167 
170  READWRITE(nTime);
171  READWRITE(vecSig);
173  }
174 
175 };
176 
177 // // can be under: DashNetwork
178 // // -- signature requirements : Key1(User)
179 // class CDashNetworkVariable : public CGovernanceObject
180 // {
181 // private:
182 
183 // public:
184 
185 // virtual uint256 GetHash(){
186 // CHashWriter ss(SER_GETHASH, PROTOCOL_VERSION);
187 // ss << strName;
188 // ss << strURL;
189 // ss << nBlockStart;
190 // ss << nBlockEnd;
191 // ss << nAmount;
192 // ss << *(CScriptBase*)(&address);
193 // ss << nGovernanceType;
194 // uint256 h1 = ss.GetHash();
195 
196 // return h1;
197 // }
198 
199 // ADD_SERIALIZE_METHODS;
200 
201 // template <typename Stream, typename Operation>
202 // virtual inline void SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) {
203 // // TODO : For testnet version bump
204 // READWRITE(nGovernanceType);
205 
206 // READWRITE(LIMITED_STRING(strName, 20));
207 // READWRITE(LIMITED_STRING(strURL, 64));
208 // READWRITE(nTime);
209 // READWRITE(vecSig);
210 // READWRITE(nCollateralHash);
211 // }
212 
213 // };
214 
215 
216 // /*
217 // ValueOverride
218 
219 // */
220 
221 // // can be under: ANY
222 // // -- signature requirements : Key1(User)
223 // template <typename VO>
224 // class CValueOverride : public CGovernanceObject
225 // {
226 
227 // // bool GetValues(VO& a)
228 // // {
229 // // return nValue1;
230 // // }
231 
232 // // bool GetValues2(VO& a, VO& b)
233 // // {
234 // // return nValue1;
235 // // }
236 
237 
238 // uint256 GetHash(){
239 // CHashWriter ss(SER_GETHASH, PROTOCOL_VERSION);
240 // ss << strName;
241 // ss << strURL;
242 // ss << nBlockStart;
243 // ss << nBlockEnd;
244 // ss << nAmount;
245 // ss << *(CScriptBase*)(&address);
246 // ss << nGovernanceType;
247 // uint256 h1 = ss.GetHash();
248 
249 // return h1;
250 // }
251 
252 // ADD_SERIALIZE_METHODS;
253 
254 // template <typename Stream, typename Operation>
255 // virtual inline void SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) {
256 // // TODO : For testnet version bump
257 // READWRITE(nGovernanceType);
258 
259 // READWRITE(LIMITED_STRING(strName, 20));
260 // READWRITE(LIMITED_STRING(strURL, 64));
261 // READWRITE(nTime);
262 // READWRITE(vecSig);
263 // READWRITE(nCollateralHash);
264 // }
265 
266 // };
267 
268 
269 // class CCategory : public CGovernanceObject
270 // {
271 // // **** Statistics / Information ****
272 
273 // CAmount GetRequiredFeeAmount() {return 1.00;}
274 // CCategory GetLevel() {return (CCategory)GetCategory(0);}
275 // CCategory GetCategoryType() {return (CCategory)GetCategory(1);}
276 // CCategory GetStatus() {return (CCategory)GetCategory(2);}
277 // CCategory GetStatusError() {return (CCategory)GetCategory(3);}
278 
279 // // isRootCategory()
280 // // {
281 // // // root categories won't have categories as parents
282 // // return (IsType() == DashNetwork);
283 // // }
284 
285 // // isSubcategoryOf(std::string strParentName)
286 // // {
287 // // CCategory parent(strParentName);
288 // // if(!parent) return false;
289 // // return isSubcategoryOf(parent);
290 // // }
291 
292 // // isSubcategoryOf(CCategory parentIn)
293 // // {
294 // // // are we related to this category?
295 // // if parent.GetHash() == pParent->GetHash():
296 // // return true
297 
298 // // return false;
299 // // }
300 
301 // // **** Governance Permissions ****
302 
303 // // only allow categories under categories
304 // virtual bool CanAdd(CCategory obj) {return true;}
305 // virtual bool RequiresSignatureToAddChild(CCategory obj) {return false;}
306 
307 // uint256 GetHash(){
308 // CHashWriter ss(SER_GETHASH, PROTOCOL_VERSION);
309 // ss << strName;
310 // ss << strURL;
311 // ss << nBlockStart;
312 // ss << nBlockEnd;
313 // ss << nAmount;
314 // ss << *(CScriptBase*)(&address);
315 // ss << nGovernanceType;
316 // uint256 h1 = ss.GetHash();
317 
318 // return h1;
319 // }
320 
321 // ADD_SERIALIZE_METHODS;
322 
323 // template <typename Stream, typename Operation>
324 // virtual inline void SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) {
325 // // TODO : For testnet version bump
326 // READWRITE(nGovernanceType);
327 
328 // READWRITE(LIMITED_STRING(strName, 20));
329 // READWRITE(LIMITED_STRING(strURL, 64));
330 // READWRITE(nTime);
331 // READWRITE(vecSig);
332 // READWRITE(nCollateralHash);
333 // }
334 // };
335 
336 // // base: actor class
337 
338 // class CGovernanceActor : public CGovernanceObject
339 // {
340 // /*
341 
342 // ???
343 
344 // GetAverageMonthlySpending();
345 // GetYearlySpent();
346 // GetContractCount(CCategory category)
347 // */
348 // };
349 
350 // class CGroup : public CGovernanceActor
351 
352 // uint256 GetHash(){
353 // CHashWriter ss(SER_GETHASH, PROTOCOL_VERSION);
354 // ss << strName;
355 // ss << strURL;
356 // ss << nBlockStart;
357 // ss << nBlockEnd;
358 // ss << nAmount;
359 // ss << *(CScriptBase*)(&address);
360 // ss << nGovernanceType;
361 // uint256 h1 = ss.GetHash();
362 
363 // return h1;
364 // }
365 
366 // };
367 
368 // class CUser : public CGovernanceActor
369 // {
370 
371 // public:
372 // uint256 GetHash(){
373 // CHashWriter ss(SER_GETHASH, PROTOCOL_VERSION);
374 // ss << strName;
375 // ss << strURL;
376 // ss << nBlockStart;
377 // ss << nBlockEnd;
378 // ss << nAmount;
379 // ss << *(CScriptBase*)(&address);
380 // ss << nGovernanceType;
381 // uint256 h1 = ss.GetHash();
382 
383 // return h1;
384 // }
385 
386 // ADD_SERIALIZE_METHODS;
387 
388 // template <typename Stream, typename Operation>
389 // virtual inline void SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) {
390 // // TODO : For testnet version bump
391 // READWRITE(nGovernanceType);
392 
393 // READWRITE(LIMITED_STRING(strName, 20));
394 // READWRITE(LIMITED_STRING(strURL, 64));
395 // READWRITE(nTime);
396 // READWRITE(vecSig);
397 // READWRITE(nCollateralHash);
398 // }
399 
400 // };
401 
402 // // base: actor classes
403 
404 // class CCompany : public CGovernanceActor
405 // {
406 
407 // uint256 GetHash(){
408 // CHashWriter ss(SER_GETHASH, PROTOCOL_VERSION);
409 // ss << strName;
410 // ss << strURL;
411 // ss << nBlockStart;
412 // ss << nBlockEnd;
413 // ss << nAmount;
414 // ss << *(CScriptBase*)(&address);
415 // ss << nGovernanceType;
416 // uint256 h1 = ss.GetHash();
417 
418 // return h1;
419 // }
420 
421 // ADD_SERIALIZE_METHODS;
422 
423 // template <typename Stream, typename Operation>
424 // virtual inline void SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) {
425 // // TODO : For testnet version bump
426 // READWRITE(nGovernanceType);
427 
428 // READWRITE(LIMITED_STRING(strName, 20));
429 // READWRITE(LIMITED_STRING(strURL, 64));
430 // READWRITE(nTime);
431 // READWRITE(vecSig);
432 // }
433 
434 // };
435 
436 // class CProject : public CGovernanceObject
437 // {
438 // public:
439 // std::string strName;
440 // std::string GetURL();
441 
442 // uint256 GetHash(){
443 // CHashWriter ss(SER_GETHASH, PROTOCOL_VERSION);
444 // ss << strName;
445 // ss << strURL;
446 // ss << nBlockStart;
447 // ss << nBlockEnd;
448 // ss << nAmount;
449 // ss << *(CScriptBase*)(&address);
450 // ss << nGovernanceType;
451 // uint256 h1 = ss.GetHash();
452 
453 // return h1;
454 // }
455 
456 // ADD_SERIALIZE_METHODS;
457 
458 // template <typename Stream, typename Operation>
459 // virtual inline void SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) {
460 // // TODO : For testnet version bump
461 // READWRITE(nGovernanceType);
462 
463 // READWRITE(LIMITED_STRING(strName, 20));
464 // READWRITE(LIMITED_STRING(strURL, 64));
465 // READWRITE(nTime);
466 // READWRITE(vecSig);
467 // }
468 
469 // };
470 
471 
472 // class CProjectReport : public CGovernanceObject
473 // {
474 // private:
475 // std::string strName;
476 // std::string GetURL;
477 
478 // public:
479 // uint256 GetHash(){
480 // CHashWriter ss(SER_GETHASH, PROTOCOL_VERSION);
481 // ss << strName;
482 // ss << strURL;
483 // ss << nBlockStart;
484 // ss << nBlockEnd;
485 // ss << nAmount;
486 // ss << *(CScriptBase*)(&address);
487 // ss << nGovernanceType;
488 // uint256 h1 = ss.GetHash();
489 
490 // return h1;
491 // }
492 
493 // ADD_SERIALIZE_METHODS;
494 
495 // template <typename Stream, typename Operation>
496 // virtual inline void SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) {
497 // // TODO : For testnet version bump
498 // READWRITE(nGovernanceType);
499 
500 // READWRITE(LIMITED_STRING(strName, 20));
501 // READWRITE(LIMITED_STRING(strURL, 64));
502 // READWRITE(nTime);
503 // READWRITE(vecSig);
504 // }
505 
506 // };
507 
508 // class CProjectMilestone : public CGovernanceObject
509 // {
510 // private:
511 // // specialized class variables
512 
513 // public:
514 // uint256 GetHash(){
515 // CHashWriter ss(SER_GETHASH, PROTOCOL_VERSION);
516 // ss << strName;
517 // ss << strURL;
518 // ss << nBlockStart;
519 // ss << nBlockEnd;
520 // ss << nAmount;
521 // ss << *(CScriptBase*)(&address);
522 // ss << nGovernanceType;
523 // uint256 h1 = ss.GetHash();
524 
525 // return h1;
526 // }
527 
528 // ADD_SERIALIZE_METHODS;
529 
530 // template <typename Stream, typename Operation>
531 // virtual inline void SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) {
532 // // TODO : For testnet version bump
533 // READWRITE(nGovernanceType);
534 
535 // READWRITE(LIMITED_STRING(strName, 20));
536 // READWRITE(LIMITED_STRING(strURL, 64));
537 // READWRITE(nTime);
538 // READWRITE(vecSig);
539 // }
540 
541 // };
542 
543 // class CProposal : public CGovernanceObject
544 // {
545 // private:
546 // // specialized class variables
547 
548 // std::string strName;
549 // std::string strURL;
550 // /*
551 // proposal will be paid on this block
552 // -- if it's not paid, it will expire unpaid
553 // */
554 // int nBlockStart;
555 // CAmount nAmount;
556 // CScript address;
557 
558 // public:
559 // // **** Statistics / Information ****
560 
561 // std::string GetName() {return strName; }
562 // CScript GetPayee() {return address;}
563 // std::string GetURL() {return strURL; }
564 
565 // // nothing can be under a proposal
566 
567 // // signatures required for everything
568 // virtual bool RequiresSignatureToAddChild(CGovernanceNode obj) {return true;}
569 
570 // uint256 GetHash(){
571 // CHashWriter ss(SER_GETHASH, PROTOCOL_VERSION);
572 // ss << strName;
573 // ss << strURL;
574 // ss << nBlockStart;
575 // ss << nBlockEnd;
576 // ss << nAmount;
577 // ss << *(CScriptBase*)(&address);
578 // ss << nGovernanceType;
579 // uint256 h1 = ss.GetHash();
580 
581 // return h1;
582 // }
583 
584 // ADD_SERIALIZE_METHODS;
585 
586 // template <typename Stream, typename Operation>
587 // virtual inline void SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) {
588 // // TODO : For testnet version bump
589 // READWRITE(nGovernanceType);
590 
591 // READWRITE(LIMITED_STRING(strName, 20));
592 // READWRITE(LIMITED_STRING(strURL, 64));
593 // READWRITE(nTime);
594 // READWRITE(vecSig);
595 // }
596 // };
597 
598 
599 // class CContract : public CGovernanceObject
600 // {
601 // private:
602 // std::string strName;
603 // std::string strURL;
604 // int nBlockStart; //starting block
605 // int months_active; //nBlockEnd = nBlockStart + (blocks-per-month * months_active)
606 // CAmount nAmount;
607 // CScript address;
608 
609 
610 // public:
611 
612 // uint256 GetHash(){
613 // CHashWriter ss(SER_GETHASH, PROTOCOL_VERSION);
614 // ss << strName;
615 // ss << strURL;
616 // ss << nBlockStart;
617 // ss << nBlockEnd;
618 // ss << nAmount;
619 // ss << *(CScriptBase*)(&address);
620 // ss << nGovernanceType;
621 // uint256 h1 = ss.GetHash();
622 
623 // return h1;
624 // }
625 
626 // ADD_SERIALIZE_METHODS;
627 
628 // template <typename Stream, typename Operation>
629 // virtual inline void SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) {
630 // // TODO : For testnet version bump
631 // READWRITE(nGovernanceType);
632 
633 // READWRITE(LIMITED_STRING(strName, 20));
634 // READWRITE(LIMITED_STRING(strURL, 64));
635 // READWRITE(nTime);
636 // READWRITE(vecSig);
637 // }
638 
639 // };
640 
641 
642 bool CreateNewGovernanceObject(UniValue& govObjJson, CGovernanceNode& govObj, GovernanceObjectType govType, std::string& strError);
643 
644 
645 #endif
std::string strStatusMessage
#define READWRITE(obj)
Definition: serialize.h:175
uint64_t nTimeValueOverrideCached
std::string strURL
bool CreateNewGovernanceObject(UniValue &govObjJson, CGovernanceNode &govObj, GovernanceObjectType govType, std::string &strError)
uint256 GetHash()
Definition: hash.h:254
std::string strName
void SerializationOp(Stream &s, Operation ser_action, int nType, int nVersion)
static const int PROTOCOL_VERSION
Definition: version.h:13
CDashNetwork(UniValue objIn)
#define LIMITED_STRING(obj, n)
Definition: serialize.h:389
uint256 nCollateralHash
fee-tx
virtual uint256 GetHash()=0
GovernanceObjectType
int64_t nTime
time this object was created
std::string get_str() const
Definition: univalue.cpp:310