]> Git Repo - VerusCoin.git/blame - src/alert.h
Introduce a CChainParameters singleton class and regtest mode.
[VerusCoin.git] / src / alert.h
CommitLineData
f35c6c4f
GA
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
15class CNode;
16
17/** Alerts are for notifying old versions if they become too obsolete and
18 * need to upgrade. The message is displayed in the status bar.
19 * Alert messages are broadcast as a vector of signed data. Unserializing may
20 * not read the entire buffer if the alert is for a newer version, but older
21 * versions can still relay the original data.
22 */
23class CUnsignedAlert
24{
25public:
26 int nVersion;
27 int64 nRelayUntil; // when newer nodes stop relaying to newer nodes
28 int64 nExpiration;
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
42 IMPLEMENT_SERIALIZE
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
67/** An alert is a combination of a serialized CUnsignedAlert and a signature. */
68class CAlert : public CUnsignedAlert
69{
70public:
71 std::vector<unsigned char> vchMsg;
72 std::vector<unsigned char> vchSig;
73
74 CAlert()
75 {
76 SetNull();
77 }
78
79 IMPLEMENT_SERIALIZE
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;
e5f163a0 94 bool ProcessAlert(bool fThread = true);
f35c6c4f
GA
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
This page took 0.046075 seconds and 4 git commands to generate.