#pragma once #include #include #include #include // Forward Declarations class IMMR; class ILeafSet; MMR_NAMESPACE /// /// Represents a collection of contiguous, unpruned leaves, /// and all hashes necessary to prove membership in the PMMR. /// struct Segment { // The requested unspent leaves, in ascending order std::vector leaves; // The MMR node hashes needed to verify the integrity of the MMR & the provided leaves std::vector hashes; // The "bagged" hash of the next lower peak (if there is one), // which is necessary to compute the PMMR root boost::optional lower_peak; }; /// /// Builds Segments for a provided MMR and segment. /// class SegmentFactory { public: static Segment Assemble( const IMMR& mmr, const ILeafSet& leafset, const LeafIndex& first_leaf_idx, const uint16_t num_leaves ); private: static std::set CalcHashIndices( const ILeafSet& leafset, const std::vector& peak_indices, const LeafIndex& first_leaf_idx, const LeafIndex& last_leaf_idx ); }; END_NAMESPACE