100template <
typename HashingPolicy>
105 bool repeated =
false;
108 for (
size_t i = 0; i < leaves_.size(); i++) {
110 if (!leaves_[i].has_value()) {
111 diff.push_back(new_value_);
116 if (leaf_value_ > new_value_) {
117 diff.push_back(leaf_value_);
118 }
else if (leaf_value_ == new_value_) {
122 diff.push_back(new_value_ - leaf_value_);
126 return std::make_pair(
static_cast<size_t>(it - diff.begin()), repeated);
Wrapper for the Nullifier leaf class that allows for 0 values.
bool has_value() const
Pass through the underlying std::optional method.
bool operator==(WrappedNullifierLeaf const &) const =default
indexed_nullifier_leaf unwrap() const
Return the wrapped nullifier_leaf object.
WrappedNullifierLeaf(indexed_nullifier_leaf value)
std::optional< indexed_nullifier_leaf > data
static WrappedNullifierLeaf< HashingPolicy > zero()
Generate a zero leaf (call the constructor with no arguments)
void set(indexed_nullifier_leaf value)
Set the wrapped nullifier_leaf object value.
bb::fr hash() const
Return the hash of the wrapped object, other return the zero hash of 0.
std::pair< size_t, bool > find_closest_leaf(std::vector< WrappedNullifierLeaf< HashingPolicy > > const &leaves_, fr const &new_value)
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept
std::vector< fr > get_hash_inputs() const
MSGPACK_FIELDS(value, nextIndex, nextValue)
std::ostream & operator<<(std::ostream &os)
bool operator==(indexed_nullifier_leaf const &) const =default
static indexed_nullifier_leaf zero()
static constexpr field zero()