h256 hash256(u256Map const& _s) { // build patricia tree. if (_s.empty()) return h256(); HexMap hexMap; for (auto i = _s.rbegin(); i != _s.rend(); ++i) hexMap[asNibbles(toBigEndianString(i->first))] = asString(rlp(i->second)); RLPStream s; hash256rlp(hexMap, hexMap.cbegin(), hexMap.cend(), 0, s); return sha3(s.out()); }
h256 hash256(StringMap const& _s) { // build patricia tree. if (_s.empty()) return h256(); HexMap hexMap; for (auto i = _s.rbegin(); i != _s.rend(); ++i) hexMap[toHex(i->first)] = i->second; RLPStream s; hash256rlp(hexMap, hexMap.cbegin(), hexMap.cend(), 0, s); return sha3(s.out()); }
void hash256aux(HexMap const& _s, HexMap::const_iterator _begin, HexMap::const_iterator _end, unsigned _preLen, RLPStream& _rlp) { RLPStream rlp; hash256rlp(_s, _begin, _end, _preLen, rlp); if (rlp.out().size() < 32) { // RECURSIVE RLP #if ENABLE_DEBUG_PRINT cerr << "[INLINE: " << dec << rlp.out().size() << " < 32]" << endl; #endif _rlp.APPEND_CHILD(rlp.out()); } else { #if ENABLE_DEBUG_PRINT cerr << "[HASH: " << dec << rlp.out().size() << " >= 32]" << endl; #endif _rlp << sha3(rlp.out()); } }