twisterp2pblockchainnetworkbittorrentmicrobloggingipv6social-networkdhtdecentralizedp2p-networktwister-servertwister-ipv6twister-coretwisterarmy
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.
73 lines
1.3 KiB
73 lines
1.3 KiB
11 years ago
|
// Copyright (c) 2014 Miguel Freitas
|
||
|
|
||
|
#ifndef SOFT_CHECKPOINT_H
|
||
|
#define SOFT_CHECKPOINT_H
|
||
|
|
||
|
#define SOFT_CHECKPOINT_PERIOD 6
|
||
|
|
||
|
#include "serialize.h"
|
||
|
#include "net.h"
|
||
|
#include "uint256.h"
|
||
|
|
||
|
#include <vector>
|
||
|
|
||
|
class CSoftCheckpoint;
|
||
|
|
||
|
/** Block-chain checkpoints are compiled-in sanity checks.
|
||
|
* They are updated every release or three.
|
||
|
*/
|
||
|
namespace SoftCheckpoints
|
||
|
{
|
||
|
extern bool fEnabled;
|
||
|
|
||
|
// Returns true if block passes checkpoint checks
|
||
|
bool CheckBlock(int nHeight, const uint256& hash);
|
||
|
|
||
|
void NewBlockAccepted();
|
||
|
|
||
|
// returns true if vote is to be restransmitted
|
||
|
bool CastVoteSoftCheckpoint(int height, const uint256 &hash, const std::string &username, const std::string &sign);
|
||
|
|
||
|
void RelayCP(const CSoftCheckpoint& cp, CNode* pfrom);
|
||
|
|
||
|
void RelayLastCPToNode(CNode* pnode);
|
||
|
}
|
||
|
|
||
|
class CSoftCheckpoint
|
||
|
{
|
||
|
public:
|
||
|
int nHeight;
|
||
|
uint256 blockHash;
|
||
|
std::vector<char> vchUsername;
|
||
|
std::vector<char> vchSign;
|
||
|
|
||
|
CSoftCheckpoint()
|
||
|
{
|
||
|
SetNull();
|
||
|
}
|
||
|
|
||
|
IMPLEMENT_SERIALIZE
|
||
|
(
|
||
|
READWRITE(nHeight);
|
||
|
READWRITE(blockHash);
|
||
|
READWRITE(vchUsername);
|
||
|
READWRITE(vchSign);
|
||
|
)
|
||
|
|
||
|
void SetNull()
|
||
|
{
|
||
|
nHeight = 0;
|
||
|
blockHash = uint256();
|
||
|
vchUsername.clear();
|
||
|
vchSign.clear();
|
||
|
}
|
||
|
|
||
|
bool IsNull() const
|
||
|
{
|
||
|
return !nHeight;
|
||
|
}
|
||
|
};
|
||
|
|
||
|
|
||
|
#endif
|