#include <cassert>
#include <stack>
#include "hotstuff/util.h"
#include "hotstuff/consensus.h"
#define LOG_INFO HOTSTUFF_LOG_INFO
#define LOG_DEBUG HOTSTUFF_LOG_DEBUG
#define LOG_WARN HOTSTUFF_LOG_WARN
#define LOG_PROTO HOTSTUFF_LOG_PROTO
namespace hotstuff {
/* The core logic of HotStuff, is fairly simple :). */
/*** begin HotStuff protocol logic ***/
HotStuffCore::HotStuffCore(ReplicaID id,
privkey_bt &&priv_key):
b0(new Block(true, 1)),
bqc(b0),
bexec(b0),
vheight(0),
priv_key(std::move(priv_key)),
tails{bqc},
neg_vote(false),
id(id),
storage(new EntityStorage()) {
storage->add_blk(b0);
b0->qc_ref = b0;
}
void HotStuffCore::sanity_check_delivered(const block_t &blk) {
if (!blk->delivered)
throw std::runtime_error("block not delivered");
}
block_t HotStuffCore::get_delivered_blk(const uint256_t &blk_hash) {
block_t blk = storage->find_blk(blk_hash);
if (blk == nullptr || !blk->delivered)