@@ -44,11 +44,8 @@ namespace libp2p::multi {
44
44
data_.insert (data_.end (), bytes.begin (), bytes.end ());
45
45
BOOST_ASSERT (hash.size () <= std::numeric_limits<uint8_t >::max ());
46
46
data_.push_back (static_cast <uint8_t >(hash.size ()));
47
- size_t size = data_.size ();
47
+ hash_offset_ = data_.size ();
48
48
data_.insert (data_.end (), hash.begin (), hash.end ());
49
-
50
- // hash_ points to a data_.begin() + size ... data_.end()
51
- hash_ = gsl::span<const uint8_t >(data_).subspan (size);
52
49
}
53
50
54
51
outcome::result<Multihash> Multihash::create (HashType type,
@@ -93,7 +90,7 @@ namespace libp2p::multi {
93
90
}
94
91
95
92
gsl::span<const uint8_t > Multihash::getHash () const {
96
- return hash_ ;
93
+ return gsl::span< const uint8_t >(data_). subspan (hash_offset_) ;
97
94
}
98
95
99
96
std::string Multihash::toHex () const {
@@ -113,8 +110,8 @@ namespace libp2p::multi {
113
110
}
114
111
115
112
bool Multihash::operator <(const class libp2p ::multi::Multihash &other) const {
116
- return this ->type_ < other.type_ ||
117
- (this ->type_ == other.type_ && this ->data_ < other.data_ );
113
+ return this ->type_ < other.type_
114
+ || (this ->type_ == other.type_ && this ->data_ < other.data_ );
118
115
}
119
116
120
117
} // namespace libp2p::multi
0 commit comments