- A7068B5BF1B556401086D790EA0E8E130206EF0E51900A45ECC79E1CBDC3B4BBAC5C89CB538BE8048825730829389A7BE7801B1DCC8B8357F107769661F9CB98
+ B877647A1FD7D468FACF6ED3488E229A15D0D88D62DCD600721943686A67FA06EFF24847A6A36C2A74B544105047636AF3E6AE4E384B55BF2863027942BD26B4
bitcoin/src/main.cpp
(1720 . 21)(1720 . 11)
5
6
7
8
9
10
11
12
13
14
15 //////////////////////////////////////////////////////////////////////////////
16 //
17 // CAlert
18 // Warnings (was: CAlert)
19 //
20
21 map<uint256, CAlert> mapAlerts;
22 CCriticalSection cs_mapAlerts;
23
24 string GetWarnings(string strFor)
25 {
26 int nPriority = 0;
(1757 . 20)(1747 . 6)
28 strStatusBar = strRPC = "WARNING: Displayed transactions may not be correct! You may need to upgrade, or other nodes may need to upgrade.";
29 }
30
31 // Alerts
32 CRITICAL_BLOCK(cs_mapAlerts)
33 {
34 BOOST_FOREACH(PAIRTYPE(const uint256, CAlert)& item, mapAlerts)
35 {
36 const CAlert& alert = item.second;
37 if (alert.AppliesToMe() && alert.nPriority > nPriority)
38 {
39 nPriority = alert.nPriority;
40 strStatusBar = alert.strStatusBar;
41 }
42 }
43 }
44
45 if (strFor == "statusbar")
46 return strStatusBar;
47 else if (strFor == "rpc")
(1779 . 59)(1755 . 6)
49 return "error";
50 }
51
52 bool CAlert::ProcessAlert()
53 {
54 if (!CheckSignature())
55 return false;
56 if (!IsInEffect())
57 return false;
58
59 CRITICAL_BLOCK(cs_mapAlerts)
60 {
61 // Cancel previous alerts
62 for (map<uint256, CAlert>::iterator mi = mapAlerts.begin(); mi != mapAlerts.end();)
63 {
64 const CAlert& alert = (*mi).second;
65 if (Cancels(alert))
66 {
67 printf("cancelling alert %d\n", alert.nID);
68 mapAlerts.erase(mi++);
69 }
70 else if (!alert.IsInEffect())
71 {
72 printf("expiring alert %d\n", alert.nID);
73 mapAlerts.erase(mi++);
74 }
75 else
76 mi++;
77 }
78
79 // Check if this alert has been cancelled
80 BOOST_FOREACH(PAIRTYPE(const uint256, CAlert)& item, mapAlerts)
81 {
82 const CAlert& alert = item.second;
83 if (alert.Cancels(*this))
84 {
85 printf("alert already cancelled by %d\n", alert.nID);
86 return false;
87 }
88 }
89
90 // Add to mapAlerts
91 mapAlerts.insert(make_pair(GetHash(), *this));
92 }
93
94 printf("accepted alert %d, AppliesToMe()=%d\n", nID, AppliesToMe());
95 MainFrameRepaint();
96 return true;
97 }
98
99
100
101
102
103
104
105
106 //////////////////////////////////////////////////////////////////////////////
107 //
(1954 . 11)(1877 . 6)
109 pfrom->PushGetBlocks(pindexBest, uint256(0));
110 }
111
112 // Relay alerts
113 CRITICAL_BLOCK(cs_mapAlerts)
114 BOOST_FOREACH(PAIRTYPE(const uint256, CAlert)& item, mapAlerts)
115 item.second.RelayTo(pfrom);
116
117 pfrom->fSuccessfullyConnected = true;
118
119 printf("version message: version %d, blocks=%d\n", pfrom->nVersion, pfrom->nStartingHeight);
(2362 . 22)(2280 . 6)
121 }
122
123
124 else if (strCommand == "alert")
125 {
126 CAlert alert;
127 vRecv >> alert;
128
129 if (alert.ProcessAlert())
130 {
131 // Relay
132 pfrom->setKnown.insert(alert.GetHash());
133 CRITICAL_BLOCK(cs_vNodes)
134 BOOST_FOREACH(CNode* pnode, vNodes)
135 alert.RelayTo(pnode);
136 }
137 }
138
139
140 else
141 {
142 // Ignore unknown commands for extensibility