|
|
@ -47,7 +47,7 @@ GCSFilter::GCSFilter(const Params& params)
|
|
|
|
: m_params(params), m_N(0), m_F(0), m_encoded{0}
|
|
|
|
: m_params(params), m_N(0), m_F(0), m_encoded{0}
|
|
|
|
{}
|
|
|
|
{}
|
|
|
|
|
|
|
|
|
|
|
|
GCSFilter::GCSFilter(const Params& params, std::vector<unsigned char> encoded_filter)
|
|
|
|
GCSFilter::GCSFilter(const Params& params, std::vector<unsigned char> encoded_filter, bool skip_decode_check)
|
|
|
|
: m_params(params), m_encoded(std::move(encoded_filter))
|
|
|
|
: m_params(params), m_encoded(std::move(encoded_filter))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
SpanReader stream{GCS_SER_TYPE, GCS_SER_VERSION, m_encoded};
|
|
|
|
SpanReader stream{GCS_SER_TYPE, GCS_SER_VERSION, m_encoded};
|
|
|
@ -59,6 +59,8 @@ GCSFilter::GCSFilter(const Params& params, std::vector<unsigned char> encoded_fi
|
|
|
|
}
|
|
|
|
}
|
|
|
|
m_F = static_cast<uint64_t>(m_N) * static_cast<uint64_t>(m_params.m_M);
|
|
|
|
m_F = static_cast<uint64_t>(m_N) * static_cast<uint64_t>(m_params.m_M);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (skip_decode_check) return;
|
|
|
|
|
|
|
|
|
|
|
|
// Verify that the encoded filter contains exactly N elements. If it has too much or too little
|
|
|
|
// Verify that the encoded filter contains exactly N elements. If it has too much or too little
|
|
|
|
// data, a std::ios_base::failure exception will be raised.
|
|
|
|
// data, a std::ios_base::failure exception will be raised.
|
|
|
|
BitStreamReader<SpanReader> bitreader{stream};
|
|
|
|
BitStreamReader<SpanReader> bitreader{stream};
|
|
|
@ -219,14 +221,14 @@ static GCSFilter::ElementSet BasicFilterElements(const CBlock& block,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
BlockFilter::BlockFilter(BlockFilterType filter_type, const uint256& block_hash,
|
|
|
|
BlockFilter::BlockFilter(BlockFilterType filter_type, const uint256& block_hash,
|
|
|
|
std::vector<unsigned char> filter)
|
|
|
|
std::vector<unsigned char> filter, bool skip_decode_check)
|
|
|
|
: m_filter_type(filter_type), m_block_hash(block_hash)
|
|
|
|
: m_filter_type(filter_type), m_block_hash(block_hash)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
GCSFilter::Params params;
|
|
|
|
GCSFilter::Params params;
|
|
|
|
if (!BuildParams(params)) {
|
|
|
|
if (!BuildParams(params)) {
|
|
|
|
throw std::invalid_argument("unknown filter_type");
|
|
|
|
throw std::invalid_argument("unknown filter_type");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
m_filter = GCSFilter(params, std::move(filter));
|
|
|
|
m_filter = GCSFilter(params, std::move(filter), skip_decode_check);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
BlockFilter::BlockFilter(BlockFilterType filter_type, const CBlock& block, const CBlockUndo& block_undo)
|
|
|
|
BlockFilter::BlockFilter(BlockFilterType filter_type, const CBlock& block, const CBlockUndo& block_undo)
|
|
|
|