Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

♻️ Changed FullNode to no longer inherit BaseNode #3574

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
21 changes: 0 additions & 21 deletions Libplanet.Store/Trie/Nodes/BaseNode.cs

This file was deleted.

15 changes: 7 additions & 8 deletions Libplanet.Store/Trie/Nodes/FullNode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,15 @@

namespace Libplanet.Store.Trie.Nodes
{
public sealed class FullNode : BaseNode, IEquatable<FullNode>
public sealed class FullNode : INode, IEquatable<FullNode>
{
// 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<INode?> children)
: base(children[ChildrenCount - 1])
{
if (children.Length != ChildrenCount)
{
Expand All @@ -23,10 +22,13 @@ public FullNode(ImmutableArray<INode?> children)
}

Children = children;
Value = children[ChildrenCount - 1];
}

public ImmutableArray<INode?> Children { get; }

public INode? Value { get; }

public FullNode SetChild(int index, INode childNode)
{
return new FullNode(Children.SetItem(index, childNode));
Expand All @@ -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();

/// <inheritdoc cref="INode.ToBencodex()"/>
public override IValue ToBencodex() =>
public IValue ToBencodex() =>
new List(Children.Select(child => child?.ToBencodex() ?? Null.Value));
}
}
Loading