6#ifndef VERIBLOCK_POP_CPP_CONTINUE_ON_INVALID_HPP
7#define VERIBLOCK_POP_CPP_CONTINUE_ON_INVALID_HPP
9#include <veriblock/pop/blockchain/alt_chain_params.hpp>
10#include <veriblock/pop/blockchain/command_group.hpp>
11#include <veriblock/pop/entities/popdata.hpp>
16struct CountingContext {
17 CountingContext(
const AltChainParams& params) : params_(params) {}
20 bool canFit(
const ATV& p)
const {
21 if (atvs >= params_.getMaxATVsInAltBlock()) {
24 size_t size = p.estimateSize();
25 return canFitSize(size);
28 bool canFit(
const VTB& p)
const {
29 if (vtbs >= params_.getMaxVTBsInAltBlock()) {
32 size_t size = p.estimateSize();
33 return canFitSize(size);
36 bool canFit(
const VbkBlock& p)
const {
37 if (vbks >= params_.getMaxVbkBlocksInAltBlock()) {
40 size_t size = p.estimateSize();
41 return canFitSize(size);
44 void update(
const ATV& p) {
45 atvs_size += p.estimateSize();
49 void update(
const VTB& p) {
50 vtbs_size += p.estimateSize();
54 void update(
const VbkBlock& p) {
55 vbks_size += p.estimateSize();
60 bool canFitSize(
size_t size)
const {
63 sizeof(PopData::version) +
64 singleBEValueSize(atvs) + atvs_size +
65 singleBEValueSize(vtbs) + vtbs_size +
66 singleBEValueSize(vbks) + vbks_size;
68 return popdatasize + size <= params_.getMaxPopDataSize();
78 const AltChainParams& params_;