blob: 6230d06549ac929f5ca2ba17721fd3ac6f59f016 (
plain) (
tree)
|
|
#include "hotstuff/hotstuff.h"
#include "hotstuff/client.h"
using salticidae::static_pointer_cast;
#define LOG_INFO HOTSTUFF_LOG_INFO
#define LOG_DEBUG HOTSTUFF_LOG_DEBUG
#define LOG_WARN HOTSTUFF_LOG_WARN
namespace hotstuff {
void MsgHotStuff::gen_propose(const Proposal &proposal) {
DataStream s;
set_opcode(PROPOSE);
s << proposal;
set_payload(std::move(s));
}
void MsgHotStuff::parse_propose(Proposal &proposal) const {
DataStream(get_payload()) >> proposal;
}
void MsgHotStuff::gen_vote(const Vote &vote) {
DataStream s;
set_opcode(VOTE);
s << vote;
set_payload(std::move(s));
}
void MsgHotStuff::parse_vote(Vote &vote) const {
DataStream(get_payload()) >> vote;
}
void MsgHotStuff::gen_qfetchblk(const std::vector<uint256_t> &blk_hashes) {
DataStream s;
set_opcode(QUERY_FETCH_BLK);
gen_hash_list(s, blk_hashes);
set_payload(std::move(s));
}
void MsgHotStuff::parse_qfetchblk(std::vector<uint256_t> &blk_hashes) const {
DataStream s(get_payload());
parse_hash_list(s, blk_hashes);
}
void MsgHotStuff::gen_rfetchblk(const std::vector<block_t> &blks) {
DataStream s;
set_opcode(RESP_FETCH_BLK);
s << htole((uint32_t)blks.size());
for (auto blk: blks) s << *blk;
set_payload(std::move(s));
}
void MsgHotStuff::parse_rfetchblk(std::vector<block_t
|