#include #include #include #include #include #include #include #include #include namespace xrpl::NodeStore { DecodedBlob::DecodedBlob(void const* key, void const* value, int valueBytes) { /* Data format: Bytes 0...7 Unused 8 char One of NodeObjectType 9...end The body of the object data */ m_success = false; m_key = key; m_objectType = NodeObjectType::hotUNKNOWN; m_objectData = nullptr; m_dataBytes = std::max(0, valueBytes - 9); // VFALCO NOTE What about bytes 4 through 7 inclusive? if (valueBytes > 8) { unsigned char const* byte = static_cast(value); m_objectType = safe_cast(byte[8]); } if (valueBytes > 9) { m_objectData = static_cast(value) + 9; switch (m_objectType) { default: break; case NodeObjectType::hotUNKNOWN: case NodeObjectType::hotLEDGER: case NodeObjectType::hotACCOUNT_NODE: case NodeObjectType::hotTRANSACTION_NODE: m_success = true; break; } } } std::shared_ptr DecodedBlob::createObject() { XRPL_ASSERT(m_success, "xrpl::NodeStore::DecodedBlob::createObject : valid object type"); std::shared_ptr object; if (m_success) { Blob data(m_objectData, m_objectData + m_dataBytes); object = NodeObject::createObject(m_objectType, std::move(data), uint256::fromVoid(m_key)); } return object; } } // namespace xrpl::NodeStore