aboutsummaryrefslogtreecommitdiff
path: root/src/entity.cpp
diff options
context:
space:
mode:
authorDeterminant <ted.sybil@gmail.com>2020-02-25 16:16:33 -0500
committerDeterminant <ted.sybil@gmail.com>2020-02-25 16:16:33 -0500
commit601fe38247a8232694a3c9af282c179e6ad1720d (patch)
treed72360651d73d67af6bc3bd51801b8fb1825d8e0 /src/entity.cpp
parent978f39fb6e01256d388bc295e4fd8138f20ef58f (diff)
bump salticidae version and make some minor changes
Diffstat (limited to 'src/entity.cpp')
-rw-r--r--src/entity.cpp16
1 files changed, 5 insertions, 11 deletions
diff --git a/src/entity.cpp b/src/entity.cpp
index 59febac..649ce19 100644
--- a/src/entity.cpp
+++ b/src/entity.cpp
@@ -26,16 +26,11 @@ void Block::serialize(DataStream &s) const {
s << htole((uint32_t)cmds.size());
for (auto cmd: cmds)
s << cmd;
- if (qc)
- s << (uint8_t)1 << *qc;
- else
- s << (uint8_t)0;
- s << htole((uint32_t)extra.size()) << extra;
+ s << *qc << htole((uint32_t)extra.size()) << extra;
}
void Block::unserialize(DataStream &s, HotStuffCore *hsc) {
uint32_t n;
- uint8_t flag;
s >> n;
n = letoh(n);
parent_hashes.resize(n);
@@ -48,8 +43,7 @@ void Block::unserialize(DataStream &s, HotStuffCore *hsc) {
s >> cmd;
// for (auto &cmd: cmds)
// cmd = hsc->parse_cmd(s);
- s >> flag;
- qc = flag ? hsc->parse_quorum_cert(s) : nullptr;
+ qc = hsc->parse_quorum_cert(s);
s >> n;
n = letoh(n);
if (n == 0)
@@ -63,12 +57,12 @@ void Block::unserialize(DataStream &s, HotStuffCore *hsc) {
}
bool Block::verify(const HotStuffCore *hsc) const {
- return qc && qc->verify(hsc->get_config());
+ if (qc->get_obj_hash() == hsc->get_genesis()->get_hash())
+ return true;
+ return qc->verify(hsc->get_config());
}
promise_t Block::verify(const HotStuffCore *hsc, VeriPool &vpool) const {
- if (!qc)
- return promise_t([](promise_t &pm) { pm.resolve(false); });
if (qc->get_obj_hash() == hsc->get_genesis()->get_hash())
return promise_t([](promise_t &pm) { pm.resolve(true); });
return qc->verify(hsc->get_config(), vpool);