static struct node *hash_lookup(unsigned long long val) { struct flist_head *l = &hash[hashv(val)]; struct flist_head *entry; struct node *n; flist_for_each(entry, l) { n = flist_entry(entry, struct node, list); if (n->val == val) return n; }
MerklePath IncrementalMerkleTree<Depth, Hash>::path(std::deque<Hash> filler_hashes) const { if (!left) { throw std::runtime_error("can't create an authentication path for the beginning of the tree"); } PathFiller<Depth, Hash> filler(filler_hashes); std::vector<Hash> path; std::vector<bool> index; if (right) { index.push_back(true); path.push_back(*left); } else { index.push_back(false); path.push_back(filler.next(0)); } size_t d = 1; BOOST_FOREACH(const boost::optional<Hash>& parent, parents) { if (parent) { index.push_back(true); path.push_back(*parent); } else { index.push_back(false); path.push_back(filler.next(d)); } d++; } while (d < Depth) { index.push_back(false); path.push_back(filler.next(d)); d++; } std::vector<std::vector<bool>> merkle_path; BOOST_FOREACH(Hash b, path) { std::vector<unsigned char> hashv(b.begin(), b.end()); merkle_path.push_back(convertBytesVectorToVector(hashv)); }