in Protocol.cpp [200:224]
bool Protocol::encodeCheckpoints(int protocolVersion, char *dest, int64_t &off,
int64_t max,
const std::vector<Checkpoint> &checkpoints) {
WDT_CHECK_GE(max, 0);
const size_t umax = static_cast<size_t>(max);
bool ok = encodeVarU64(dest, umax, off, checkpoints.size());
for (const auto &checkpoint : checkpoints) {
if (!ok) {
break;
}
ok = encodeVarI64C(dest, umax, off, checkpoint.port) &&
encodeVarI64C(dest, umax, off, checkpoint.numBlocks);
if (ok && protocolVersion >= CHECKPOINT_OFFSET_VERSION) {
ok = encodeVarI64C(dest, umax, off, checkpoint.lastBlockReceivedBytes);
}
if (ok && protocolVersion >= CHECKPOINT_SEQ_ID_VERSION) {
ok = encodeVarI64C(dest, umax, off, checkpoint.lastBlockSeqId) &&
encodeVarI64C(dest, umax, off, checkpoint.lastBlockOffset);
}
}
if (!ok) {
WLOG(ERROR) << "encodeCheckpoints " << off << " " << max;
}
return ok;
}