diff --git a/CHANGES.md b/CHANGES.md index 071356e36ef..af80c22dc00 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -35,6 +35,9 @@ be compatible with this version, specifically, those that ran with - (Libplanet.Store) Removed `FullNode()` and added `FullNode.Empty`. [[#3573]] - (Libplanet.Store) Slightly optimized `ITrie` performance. [[#3573]] + - (Libplanet.Store) Changed `FullNode` to no longer inherit `BaseNode`. + [[#3574]] + - (Libplanet.Store) Removed `BaseNode`. [[#3574]] [#3559]: https://github.com/planetarium/libplanet/pull/3559 [#3560]: https://github.com/planetarium/libplanet/pull/3560 @@ -44,6 +47,7 @@ be compatible with this version, specifically, those that ran with [#3567]: https://github.com/planetarium/libplanet/pull/3567 [#3572]: https://github.com/planetarium/libplanet/pull/3572 [#3573]: https://github.com/planetarium/libplanet/pull/3573 +[#3574]: https://github.com/planetarium/libplanet/pull/3574 Version 3.9.2 diff --git a/Libplanet.Store/Trie/Nodes/BaseNode.cs b/Libplanet.Store/Trie/Nodes/BaseNode.cs deleted file mode 100644 index bdd9bb223b4..00000000000 --- a/Libplanet.Store/Trie/Nodes/BaseNode.cs +++ /dev/null @@ -1,21 +0,0 @@ -using Bencodex.Types; - -namespace Libplanet.Store.Trie.Nodes -{ - /// - /// Represents a node in MPT that can have a value. - /// - public abstract class BaseNode : INode - { - protected BaseNode(INode? value) - { - Value = value; - } - - // It will not support embedded node. - public INode? Value { get; } - - /// - public abstract IValue ToBencodex(); - } -} diff --git a/Libplanet.Store/Trie/Nodes/FullNode.cs b/Libplanet.Store/Trie/Nodes/FullNode.cs index 4557af7c1df..9f3abe6de6a 100644 --- a/Libplanet.Store/Trie/Nodes/FullNode.cs +++ b/Libplanet.Store/Trie/Nodes/FullNode.cs @@ -5,16 +5,15 @@ namespace Libplanet.Store.Trie.Nodes { - public sealed class FullNode : BaseNode, IEquatable + public sealed class FullNode : INode, IEquatable { - // Children 0x10 + Value 0x1 + // Children 0x10 + Value 0x01 public const byte ChildrenCount = 0x11; public static readonly FullNode Empty = new FullNode(new INode?[ChildrenCount].ToImmutableArray()); public FullNode(ImmutableArray children) - : base(children[ChildrenCount - 1]) { if (children.Length != ChildrenCount) { @@ -23,10 +22,13 @@ public FullNode(ImmutableArray children) } Children = children; + Value = children[ChildrenCount - 1]; } public ImmutableArray Children { get; } + public INode? Value { get; } + public FullNode SetChild(int index, INode childNode) { return new FullNode(Children.SetItem(index, childNode)); @@ -48,13 +50,10 @@ public bool Equals(FullNode? other) public override bool Equals(object? obj) => obj is FullNode other && Equals(other); - public override int GetHashCode() - { - return Children.GetHashCode(); - } + public override int GetHashCode() => Children.GetHashCode(); /// - public override IValue ToBencodex() => + public IValue ToBencodex() => new List(Children.Select(child => child?.ToBencodex() ?? Null.Value)); } }