Skip to content

Commit

Permalink
Tree merging operation looks like working.
Browse files Browse the repository at this point in the history
All tests working just fine.
  • Loading branch information
rodoufu committed Nov 15, 2018
1 parent 897c99c commit 6e5bc05
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
6 changes: 2 additions & 4 deletions NeoDataStructure/MerklePatricia.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
using System;

namespace com.github.neoresearch.NeoDataStructure
{
using System.Text;
Expand Down Expand Up @@ -400,15 +398,15 @@ private string Merge(MerklePatricia mpA, MerklePatricia mpB, string hashA, strin
nodeHash = MergeCopy(hashA, mpA);
node = _db[nodeHash];
_db.Remove(nodeHash);
nodeHash = Set(node, 2 + nodeB[0].Length % 2 + lastNibble + nodeB[0].Substring(1), nodeB[1], nodeB[2]);
nodeHash = Set(node, nodeB[0].Substring(1), nodeB[1], nodeB[2]);
node = _db[nodeHash];
}
else if (nodeB.Length == NodeSize)
{
nodeHash = MergeCopy(hashB, mpB);
node = _db[nodeHash];
_db.Remove(nodeHash);
nodeHash = Set(node, 2 + nodeA[0].Length % 2 + lastNibble + nodeA[0].Substring(1), nodeA[1], nodeA[2]);
nodeHash = Set(node, nodeA[0].Substring(1), nodeA[1], nodeA[2]);
node = _db[nodeHash];
}

Expand Down
2 changes: 1 addition & 1 deletion NeoDataStructureTest/MerklePatriciaMergeTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ public void Merge()
};
Assert.True(mpD.Validade());
System.Console.WriteLine($"C:{mpC}");
System.Console.WriteLine($"D:{mpD}");
System.Console.WriteLine($"merge:{mpMerge}");
Assert.Equal(mpC, mpD);

Assert.Equal(mpC, mpMerge);
Expand Down

0 comments on commit 6e5bc05

Please sign in to comment.