Hush Full Node software. We were censored from Github, this is where all development happens now.
https://hush.is
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
128 lines
4.3 KiB
128 lines
4.3 KiB
// Copyright (c) 2010 Satoshi Nakamoto
|
|
// Copyright (c) 2009-2013 The Bitcoin Core developers
|
|
// Copyright (c) 2019-2020 The Hush developers
|
|
// Distributed under the GPLv3 software license, see the accompanying
|
|
// file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html
|
|
|
|
/******************************************************************************
|
|
* Copyright © 2014-2019 The SuperNET Developers. *
|
|
* *
|
|
* See the AUTHORS, DEVELOPER-AGREEMENT and LICENSE files at *
|
|
* the top-level directory of this distribution for the individual copyright *
|
|
* holder information and the developer policies on copyright and licensing. *
|
|
* *
|
|
* Unless otherwise agreed in a custom licensing agreement, no part of the *
|
|
* SuperNET software, including this file may be copied, modified, propagated *
|
|
* or distributed except according to the terms contained in the LICENSE file *
|
|
* *
|
|
* Removal or modification of this copyright notice is prohibited. *
|
|
* *
|
|
******************************************************************************/
|
|
|
|
#ifndef BITCOIN_ALERT_H
|
|
#define BITCOIN_ALERT_H
|
|
|
|
#include "serialize.h"
|
|
#include "sync.h"
|
|
|
|
#include <map>
|
|
#include <set>
|
|
#include <stdint.h>
|
|
#include <string>
|
|
|
|
class CAlert;
|
|
class CNode;
|
|
class uint256;
|
|
|
|
extern std::map<uint256, CAlert> mapAlerts;
|
|
extern CCriticalSection cs_mapAlerts;
|
|
|
|
/** Alerts are for notifying old versions if they become too obsolete and
|
|
* need to upgrade. The message is displayed in the status bar.
|
|
* Alert messages are broadcast as a vector of signed data. Unserializing may
|
|
* not read the entire buffer if the alert is for a newer version, but older
|
|
* versions can still relay the original data.
|
|
*/
|
|
class CUnsignedAlert
|
|
{
|
|
public:
|
|
int nVersion;
|
|
int64_t nRelayUntil; // when newer nodes stop relaying to newer nodes
|
|
int64_t nExpiration;
|
|
int nID;
|
|
int nCancel;
|
|
std::set<int> setCancel;
|
|
int nMinVer; // lowest version inclusive
|
|
int nMaxVer; // highest version inclusive
|
|
std::set<std::string> setSubVer; // empty matches all
|
|
int nPriority;
|
|
|
|
// Actions
|
|
std::string strComment;
|
|
std::string strStatusBar;
|
|
std::string strRPCError;
|
|
|
|
ADD_SERIALIZE_METHODS;
|
|
|
|
template <typename Stream, typename Operation>
|
|
inline void SerializationOp(Stream& s, Operation ser_action) {
|
|
READWRITE(this->nVersion);
|
|
READWRITE(nRelayUntil);
|
|
READWRITE(nExpiration);
|
|
READWRITE(nID);
|
|
READWRITE(nCancel);
|
|
READWRITE(setCancel);
|
|
READWRITE(nMinVer);
|
|
READWRITE(nMaxVer);
|
|
READWRITE(setSubVer);
|
|
READWRITE(nPriority);
|
|
|
|
READWRITE(LIMITED_STRING(strComment, 65536));
|
|
READWRITE(LIMITED_STRING(strStatusBar, 256));
|
|
READWRITE(LIMITED_STRING(strRPCError, 256));
|
|
}
|
|
|
|
void SetNull();
|
|
|
|
std::string ToString() const;
|
|
};
|
|
|
|
/** An alert is a combination of a serialized CUnsignedAlert and a signature. */
|
|
class CAlert : public CUnsignedAlert
|
|
{
|
|
public:
|
|
std::vector<unsigned char> vchMsg;
|
|
std::vector<unsigned char> vchSig;
|
|
|
|
CAlert()
|
|
{
|
|
SetNull();
|
|
}
|
|
|
|
ADD_SERIALIZE_METHODS;
|
|
|
|
template <typename Stream, typename Operation>
|
|
inline void SerializationOp(Stream& s, Operation ser_action) {
|
|
READWRITE(vchMsg);
|
|
READWRITE(vchSig);
|
|
}
|
|
|
|
void SetNull();
|
|
bool IsNull() const;
|
|
uint256 GetHash() const;
|
|
bool IsInEffect() const;
|
|
bool Cancels(const CAlert& alert) const;
|
|
bool AppliesTo(int nVersion, const std::string& strSubVerIn) const;
|
|
bool AppliesToMe() const;
|
|
bool RelayTo(CNode* pnode) const;
|
|
bool CheckSignature(const std::vector<unsigned char>& alertKey) const;
|
|
bool ProcessAlert(const std::vector<unsigned char>& alertKey, bool fThread = true); // fThread means run -alertnotify in a free-running thread
|
|
static void Notify(const std::string& strMessage, bool fThread);
|
|
|
|
/*
|
|
* Get copy of (active) alert object by hash. Returns a null alert if it is not found.
|
|
*/
|
|
static CAlert getAlertByHash(const uint256 &hash);
|
|
};
|
|
|
|
#endif // BITCOIN_ALERT_H
|
|
|