blob: 03e55284321b2c7849d4ce11aff117d1f87a6d6c (
plain) (
tree)
|
|
/**
* Copyright 2018 VMware
* Copyright 2018 Ted Yin
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#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)) {}
|