aboutsummaryrefslogtreecommitdiff
path: root/include/hotstuff/entity.h
diff options
context:
space:
mode:
authorDeterminant <[email protected]>2018-07-27 17:33:23 -0400
committerDeterminant <[email protected]>2018-07-27 17:33:23 -0400
commitec6a1f84324faf8e7c92f32137464db57410f58a (patch)
tree10a0f289a255eb5c78be2cb4a5e2702fc7995182 /include/hotstuff/entity.h
parent5f00c067f863f812a740dc209b1fb829f04042eb (diff)
fix signature verification bug
Diffstat (limited to 'include/hotstuff/entity.h')
-rw-r--r--include/hotstuff/entity.h11
1 files changed, 10 insertions, 1 deletions
diff --git a/include/hotstuff/entity.h b/include/hotstuff/entity.h
index 1fca18c..ba3906b 100644
--- a/include/hotstuff/entity.h
+++ b/include/hotstuff/entity.h
@@ -44,10 +44,14 @@ class ReplicaConfig {
std::unordered_map<ReplicaID, ReplicaInfo> replica_map;
public:
+ size_t nreplicas;
size_t nmajority;
+ ReplicaConfig(): nreplicas(0), nmajority(0) {}
+
void add_replica(ReplicaID rid, const ReplicaInfo &info) {
replica_map.insert(std::make_pair(rid, info));
+ nreplicas++;
}
const ReplicaInfo &get_info(ReplicaID rid) const {
@@ -209,7 +213,12 @@ class EntityStorage {
return blk_cache.count(blk_hash);
}
- const block_t &add_blk(Block &&_blk) {
+ block_t add_blk(Block &&_blk, const ReplicaConfig &config) {
+ if (!_blk.verify(config))
+ {
+ HOTSTUFF_LOG_WARN("block is invalid");
+ return nullptr;
+ }
block_t blk = new Block(std::move(_blk));
return blk_cache.insert(std::make_pair(blk->get_hash(), blk)).first->second;
}