alert.h 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. // ECOin - Copyright (c) - 2014/2022 - GPLv3 - epsylon@riseup.net (https://03c8.net)
  2. #ifndef _ECOINALERT_H_
  3. #define _ECOINALERT_H_ 1
  4. #include <set>
  5. #include <string>
  6. #include "uint256.h"
  7. #include "util.h"
  8. class CNode;
  9. class CUnsignedAlert
  10. {
  11. public:
  12. int nVersion;
  13. int64 nRelayUntil; // when newer nodes stop relaying to newer nodes
  14. int64 nExpiration;
  15. int nID;
  16. int nCancel;
  17. std::set<int> setCancel;
  18. int nMinVer; // lowest version inclusive
  19. int nMaxVer; // highest version inclusive
  20. std::set<std::string> setSubVer; // empty matches all
  21. int nPriority;
  22. // Actions
  23. std::string strComment;
  24. std::string strStatusBar;
  25. std::string strReserved;
  26. IMPLEMENT_SERIALIZE
  27. (
  28. READWRITE(this->nVersion);
  29. nVersion = this->nVersion;
  30. READWRITE(nRelayUntil);
  31. READWRITE(nExpiration);
  32. READWRITE(nID);
  33. READWRITE(nCancel);
  34. READWRITE(setCancel);
  35. READWRITE(nMinVer);
  36. READWRITE(nMaxVer);
  37. READWRITE(setSubVer);
  38. READWRITE(nPriority);
  39. READWRITE(strComment);
  40. READWRITE(strStatusBar);
  41. READWRITE(strReserved);
  42. )
  43. void SetNull();
  44. std::string ToString() const;
  45. void print() const;
  46. };
  47. class CAlert : public CUnsignedAlert
  48. {
  49. public:
  50. std::vector<unsigned char> vchMsg;
  51. std::vector<unsigned char> vchSig;
  52. CAlert()
  53. {
  54. SetNull();
  55. }
  56. IMPLEMENT_SERIALIZE
  57. (
  58. READWRITE(vchMsg);
  59. READWRITE(vchSig);
  60. )
  61. void SetNull();
  62. bool IsNull() const;
  63. uint256 GetHash() const;
  64. bool IsInEffect() const;
  65. bool Cancels(const CAlert& alert) const;
  66. bool AppliesTo(int nVersion, std::string strSubVerIn) const;
  67. bool AppliesToMe() const;
  68. bool RelayTo(CNode* pnode) const;
  69. bool CheckSignature() const;
  70. bool ProcessAlert();
  71. static CAlert getAlertByHash(const uint256 &hash);
  72. };
  73. #endif