Changeset View
Changeset View
Standalone View
Standalone View
src/blockfilter.h
Show First 20 Lines • Show All 136 Lines • ▼ Show 20 Lines | public: | ||||
//! Compute the filter hash. | //! Compute the filter hash. | ||||
uint256 GetHash() const; | uint256 GetHash() const; | ||||
//! Compute the filter header given the previous one. | //! Compute the filter header given the previous one. | ||||
uint256 ComputeHeader(const uint256 &prev_header) const; | uint256 ComputeHeader(const uint256 &prev_header) const; | ||||
template <typename Stream> void Serialize(Stream &s) const { | template <typename Stream> void Serialize(Stream &s) const { | ||||
s << m_block_hash << static_cast<uint8_t>(m_filter_type) | s << static_cast<uint8_t>(m_filter_type) << m_block_hash | ||||
<< m_filter.GetEncoded(); | << m_filter.GetEncoded(); | ||||
} | } | ||||
template <typename Stream> void Unserialize(Stream &s) { | template <typename Stream> void Unserialize(Stream &s) { | ||||
std::vector<uint8_t> encoded_filter; | std::vector<uint8_t> encoded_filter; | ||||
uint8_t filter_type; | uint8_t filter_type; | ||||
s >> m_block_hash >> filter_type >> encoded_filter; | s >> filter_type >> m_block_hash >> encoded_filter; | ||||
m_filter_type = static_cast<BlockFilterType>(filter_type); | m_filter_type = static_cast<BlockFilterType>(filter_type); | ||||
GCSFilter::Params params; | GCSFilter::Params params; | ||||
if (!BuildParams(params)) { | if (!BuildParams(params)) { | ||||
throw std::ios_base::failure("unknown filter_type"); | throw std::ios_base::failure("unknown filter_type"); | ||||
} | } | ||||
m_filter = GCSFilter(params, std::move(encoded_filter)); | m_filter = GCSFilter(params, std::move(encoded_filter)); | ||||
} | } | ||||
}; | }; | ||||
#endif // BITCOIN_BLOCKFILTER_H | #endif // BITCOIN_BLOCKFILTER_H |