// Alert system
//
-#include <boost/foreach.hpp>
-#include <map>
-
#include "alert.h"
#include "key.h"
#include "net.h"
#include "sync.h"
-#include "ui_interface.h"
+#include "interface.h"
using namespace std;
std::string CUnsignedAlert::ToString() const
{
std::string strSetCancel;
- BOOST_FOREACH(int n, setCancel)
+ for (int n : setCancel)
strSetCancel += strprintf("%d ", n);
std::string strSetSubVer;
- BOOST_FOREACH(std::string str, setSubVer)
+ for (const std::string& str : setSubVer)
strSetSubVer += "\"" + str + "\" ";
return strprintf(
"CAlert(\n"
" nVersion = %d\n"
- " nRelayUntil = %" PRI64d "\n"
- " nExpiration = %" PRI64d "\n"
+ " nRelayUntil = %" PRId64 "\n"
+ " nExpiration = %" PRId64 "\n"
" nID = %d\n"
" nCancel = %d\n"
" setCancel = %s\n"
strStatusBar.c_str());
}
-void CUnsignedAlert::print() const
-{
- printf("%s", ToString().c_str());
-}
-
void CAlert::SetNull()
{
CUnsignedAlert::SetNull();
return (alert.nID <= nCancel || setCancel.count(alert.nID));
}
-bool CAlert::AppliesTo(int nVersion, std::string strSubVerIn) const
+bool CAlert::AppliesTo(int nVersion, const std::string& strSubVerIn) const
{
// TODO: rework for client-version-embedded-in-strSubVer ?
return (IsInEffect() &&
bool CAlert::CheckSignature() const
{
- CKey key;
- if (!key.SetPubKey(ParseHex(fTestNet ? pszTestKey : pszMainKey)))
- return error("CAlert::CheckSignature() : SetPubKey failed");
+ CPubKey key;
+ key.Set(ParseHex(fTestNet ? pszTestKey : pszMainKey));
if (!key.Verify(Hash(vchMsg.begin(), vchMsg.end()), vchSig))
return error("CAlert::CheckSignature() : verify signature failed");
CAlert retval;
{
LOCK(cs_mapAlerts);
- map<uint256, CAlert>::iterator mi = mapAlerts.find(hash);
+ auto mi = mapAlerts.find(hash);
if(mi != mapAlerts.end())
retval = mi->second;
}
{
LOCK(cs_mapAlerts);
// Cancel previous alerts
- for (map<uint256, CAlert>::iterator mi = mapAlerts.begin(); mi != mapAlerts.end();)
+ for (auto mi = mapAlerts.begin(); mi != mapAlerts.end();)
{
const CAlert& alert = (*mi).second;
if (Cancels(alert))
}
// Check if this alert has been cancelled
- BOOST_FOREACH(PAIRTYPE(const uint256, CAlert)& item, mapAlerts)
+ for (auto& item : mapAlerts)
{
const CAlert& alert = item.second;
if (alert.Cancels(*this))