Feathercoin  0.5.0
P2P Digital Currency
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros
alert.h
Go to the documentation of this file.
1 // Copyright (c) 2010 Satoshi Nakamoto
2 // Copyright (c) 2009-2012 The Bitcoin developers
3 // Distributed under the MIT/X11 software license, see the accompanying
4 // file COPYING or http://www.opensource.org/licenses/mit-license.php.
5 
6 #ifndef _BITCOINALERT_H_
7 #define _BITCOINALERT_H_ 1
8 
9 #include <set>
10 #include <string>
11 
12 #include "uint256.h"
13 #include "util.h"
14 
15 class CNode;
16 
24 {
25 public:
26  int nVersion;
27  int64 nRelayUntil; // when newer nodes stop relaying to newer nodes
29  int nID;
30  int nCancel;
31  std::set<int> setCancel;
32  int nMinVer; // lowest version inclusive
33  int nMaxVer; // highest version inclusive
34  std::set<std::string> setSubVer; // empty matches all
35  int nPriority;
36 
37  // Actions
38  std::string strComment;
39  std::string strStatusBar;
40  std::string strReserved;
41 
43  (
44  READWRITE(this->nVersion);
45  nVersion = this->nVersion;
46  READWRITE(nRelayUntil);
47  READWRITE(nExpiration);
48  READWRITE(nID);
49  READWRITE(nCancel);
50  READWRITE(setCancel);
51  READWRITE(nMinVer);
52  READWRITE(nMaxVer);
53  READWRITE(setSubVer);
54  READWRITE(nPriority);
55 
56  READWRITE(strComment);
57  READWRITE(strStatusBar);
58  READWRITE(strReserved);
59  )
60 
61  void SetNull();
62 
63  std::string ToString() const;
64  void print() const;
65 };
66 
68 class CAlert : public CUnsignedAlert
69 {
70 public:
71  std::vector<unsigned char> vchMsg;
72  std::vector<unsigned char> vchSig;
73 
75  {
76  SetNull();
77  }
78 
80  (
81  READWRITE(vchMsg);
82  READWRITE(vchSig);
83  )
84 
85  void SetNull();
86  bool IsNull() const;
87  uint256 GetHash() const;
88  bool IsInEffect() const;
89  bool Cancels(const CAlert& alert) const;
90  bool AppliesTo(int nVersion, std::string strSubVerIn) const;
91  bool AppliesToMe() const;
92  bool RelayTo(CNode* pnode) const;
93  bool CheckSignature() const;
94  bool ProcessAlert(bool fThread = true);
95 
96  /*
97  * Get copy of (active) alert object by hash. Returns a null alert if it is not found.
98  */
99  static CAlert getAlertByHash(const uint256 &hash);
100 };
101 
102 #endif
std::set< std::string > setSubVer
Definition: alert.h:34
IMPLEMENT_SERIALIZE(READWRITE(this->nVersion);nVersion=this->nVersion;READWRITE(nRelayUntil);READWRITE(nExpiration);READWRITE(nID);READWRITE(nCancel);READWRITE(setCancel);READWRITE(nMinVer);READWRITE(nMaxVer);READWRITE(setSubVer);READWRITE(nPriority);READWRITE(strComment);READWRITE(strStatusBar);READWRITE(strReserved);) void SetNull()
std::string strReserved
Definition: alert.h:40
#define READWRITE(obj)
Definition: serialize.h:93
int64 nExpiration
Definition: alert.h:28
std::vector< unsigned char > vchMsg
Definition: alert.h:71
bool AppliesTo(int nVersion, std::string strSubVerIn) const
Definition: alert.cpp:114
bool ProcessAlert(bool fThread=true)
Definition: alert.cpp:169
int nVersion
Definition: alert.h:26
IMPLEMENT_SERIALIZE(READWRITE(vchMsg);READWRITE(vchSig);) void SetNull()
std::string strStatusBar
Definition: alert.h:39
bool IsInEffect() const
Definition: alert.cpp:102
void print() const
Definition: alert.cpp:80
int64 nRelayUntil
Definition: alert.h:27
bool IsNull() const
Definition: alert.cpp:92
An alert is a combination of a serialized CUnsignedAlert and a signature.
Definition: alert.h:68
uint256 GetHash() const
Definition: alert.cpp:97
std::string ToString() const
Definition: alert.cpp:43
Alerts are for notifying old versions if they become too obsolete and need to upgrade.
Definition: alert.h:23
int nMaxVer
Definition: alert.h:33
std::vector< unsigned char > vchSig
Definition: alert.h:72
256-bit unsigned integer
Definition: uint256.h:537
CAlert()
Definition: alert.h:74
bool RelayTo(CNode *pnode) const
Definition: alert.cpp:127
std::set< int > setCancel
Definition: alert.h:31
static CAlert getAlertByHash(const uint256 &hash)
Definition: alert.cpp:157
int nMinVer
Definition: alert.h:32
bool CheckSignature() const
Definition: alert.cpp:145
std::string strComment
Definition: alert.h:38
bool Cancels(const CAlert &alert) const
Definition: alert.cpp:107
int nCancel
Definition: alert.h:30
Information about a peer.
Definition: net.h:154
bool AppliesToMe() const
Definition: alert.cpp:122
uint32_t hash
Definition: cache.cc:34
long long int64
Definition: serialize.h:25
int nPriority
Definition: alert.h:35