in platform/consensus/ordering/pbft/checkpoint_manager.cpp [106:152]
int CheckPointManager::ProcessCheckPoint(std::unique_ptr<Context> context,
std::unique_ptr<Request> request) {
CheckPointData checkpoint_data;
if (!checkpoint_data.ParseFromString(request->data())) {
LOG(ERROR) << "parse checkpont data fail:";
return -2;
}
uint64_t checkpoint_seq = checkpoint_data.seq();
uint32_t sender_id = request->sender_id();
int water_mark = config_.GetCheckPointWaterMark();
if (checkpoint_seq % water_mark) {
LOG(ERROR) << "checkpoint seq not invalid:" << checkpoint_seq;
return -2;
}
if (verifier_) {
// check signatures
bool valid = verifier_->VerifyMessage(checkpoint_data.hash(),
checkpoint_data.hash_signature());
if (!valid) {
LOG(ERROR) << "request is not valid:"
<< checkpoint_data.hash_signature().DebugString();
return -2;
}
}
{
std::lock_guard<std::mutex> lk(mutex_);
auto res =
sender_ckpt_[std::make_pair(checkpoint_seq, checkpoint_data.hash())]
.insert(sender_id);
if (res.second) {
sign_ckpt_[std::make_pair(checkpoint_seq, checkpoint_data.hash())]
.push_back(checkpoint_data.hash_signature());
new_data_++;
}
if (sender_ckpt_[std::make_pair(checkpoint_seq, checkpoint_data.hash())]
.size() == 1) {
for (auto& hash_ : checkpoint_data.hashs()) {
hash_ckpt_[std::make_pair(checkpoint_seq, checkpoint_data.hash())]
.push_back(hash_);
}
}
Notify();
}
return 0;
}