blob: bc8d96035967d7bac41b4659b5fcd8d5216cf4ec (
plain) (
tree)
|
|
#ifndef _HOTSTUFF_CORE_H
#define _HOTSTUFF_CORE_H
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include "salticidae/util.h"
#include "salticidae/network.h"
#include "salticidae/msg.h"
#include "hotstuff/util.h"
#include "hotstuff/consensus.h"
#include "hotstuff/liveness.h"
namespace hotstuff {
using salticidae::PeerNetwork;
using salticidae::ElapsedTime;
using salticidae::_1;
using salticidae::_2;
const double ent_waiting_timeout = 10;
const double double_inf = 1e10;
/** Network message format for HotStuff. */
struct MsgPropose {
static const opcode_t opcode = 0x0;
DataStream serialized;
Proposal proposal;
MsgPropose(const Proposal &);
/** Only move the data to serialized, do not parse immediately. */
MsgPropose(DataStream &&s): serialized(std::move(s)) {}
/** Parse the serialized data to blks now, with `hsc->storage`. */
void postponed_parse(HotStuffCore *hsc);
};
struct MsgVote {
static const opcode_t opcode = 0x1;
DataStream serialized;
Vote vote;
MsgVote(const Vote &);
MsgVote(DataStream &&s): serialized(std::move(s)) {}
void postponed_parse(HotStuffCore *hsc);
};
struct MsgReqBlock {
static const opcode_t opcode = 0x2;
DataStream serialized;
std::vector<uint256_t> blk_hashes;
MsgReqBlock() = default;
MsgReqBlock(const std::vector<uint256_t> &blk_hashes);
MsgReqBlock(DataStream &&s);
};
struct MsgRespBlock {
static const opcode_t opcode = 0x3;
DataStream serialized;
std::vector<block_t> blks;
MsgRespBlock(const std::vector<block_t> &
|