aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/consensus.cpp10
-rw-r--r--src/entity.cpp16
2 files changed, 16 insertions, 10 deletions
diff --git a/src/consensus.cpp b/src/consensus.cpp
index 2cac22c..e25558a 100644
--- a/src/consensus.cpp
+++ b/src/consensus.cpp
@@ -109,7 +109,8 @@ bool HotStuffCore::update(const uint256_t &bqc_hash) {
}
void HotStuffCore::on_propose(const std::vector<command_t> &cmds,
- const std::vector<block_t> &parents) {
+ const std::vector<block_t> &parents,
+ serializable_bt &&extra) {
if (parents.empty())
throw std::runtime_error("empty parents");
for (const auto &_: parents) tails.erase(_);
@@ -125,11 +126,10 @@ void HotStuffCore::on_propose(const std::vector<command_t> &cmds,
}
/* create the new block */
block_t bnew = storage->add_blk(
- new Block(
- parents,
- cmds,
+ new Block(parents, cmds,
+ std::move(qc), std::move(extra),
p->height + 1,
- std::move(qc), qc_ref,
+ qc_ref,
nullptr
));
const uint256_t bnew_hash = bnew->get_hash();
diff --git a/src/entity.cpp b/src/entity.cpp
index 80c9cf9..a5dc44e 100644
--- a/src/entity.cpp
+++ b/src/entity.cpp
@@ -10,15 +10,19 @@ void Block::serialize(DataStream &s) const {
s << (uint32_t)cmds.size();
for (auto cmd: cmds)
s << *cmd;
- if (qc == nullptr)
+ if (qc)
+ s << (uint8_t)1 << *qc;
+ else
s << (uint8_t)0;
+ if (extra)
+ s << (uint8_t)1 << *extra;
else
- s << (uint8_t)1 << *qc;
+ s << (uint8_t)0;
}
void Block::unserialize(DataStream &s, HotStuffCore *hsc) {
uint32_t n;
- uint8_t has_qc;
+ uint8_t flag;
s >> n;
parent_hashes.resize(n);
for (auto &hash: parent_hashes)
@@ -27,9 +31,11 @@ void Block::unserialize(DataStream &s, HotStuffCore *hsc) {
cmds.resize(n);
for (auto &cmd: cmds)
cmd = hsc->parse_cmd(s);
- s >> has_qc;
- qc = has_qc ? hsc->parse_quorum_cert(s) : nullptr;
+ s >> flag;
+ qc = flag ? hsc->parse_quorum_cert(s) : nullptr;
this->hash = salticidae::get_hash(*this);
+ s >> flag;
+ extra = flag ? hsc->parse_extra_block_data(s) : nullptr;
}
}