Skip to content

Commit

Permalink
mpt: reorder implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
chfast committed Jun 16, 2022
1 parent 1b2aabb commit 2cbe6b0
Showing 1 changed file with 19 additions and 18 deletions.
37 changes: 19 additions & 18 deletions test/state/mpt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,24 +123,6 @@ class MPTNode
[[nodiscard]] hash256 hash() const;
};

MPT::MPT() noexcept = default;
MPT::~MPT() noexcept = default;

void MPT::insert(bytes_view key, bytes&& value)
{
if (m_root == nullptr)
m_root = std::make_unique<MPTNode>(MPTNode::leaf(Path{key}, std::move(value)));
else
m_root->insert(Path{key}, std::move(value));
}

[[nodiscard]] hash256 MPT::hash() const
{
if (m_root == nullptr)
return emptyMPTHash;
return m_root->hash();
}

void MPTNode::insert(const Path& path, bytes&& value) // NOLINT(misc-no-recursion)
{
switch (m_kind)
Expand Down Expand Up @@ -282,4 +264,23 @@ hash256 MPTNode::hash() const // NOLINT(misc-no-recursion)
return r;
}


MPT::MPT() noexcept = default;
MPT::~MPT() noexcept = default;

void MPT::insert(bytes_view key, bytes&& value)
{
if (m_root == nullptr)
m_root = std::make_unique<MPTNode>(MPTNode::leaf(Path{key}, std::move(value)));
else
m_root->insert(Path{key}, std::move(value));
}

[[nodiscard]] hash256 MPT::hash() const
{
if (m_root == nullptr)
return emptyMPTHash;
return m_root->hash();
}

} // namespace evmone::state

0 comments on commit 2cbe6b0

Please sign in to comment.