-
Notifications
You must be signed in to change notification settings - Fork 1k
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
[Change
] DataCache to Match LevelDbStore & RocksDbStore
#3709
base: master
Are you sure you want to change the base?
[Change
] DataCache to Match LevelDbStore & RocksDbStore
#3709
Conversation
Change
] DataCache to Match LevelDbStore & RocksDbStore
return y.AsSpan().SequenceCompareTo(x.AsSpan()); | ||
return x.AsSpan().SequenceCompareTo(y.AsSpan()); | ||
|
||
return x.AsSpan().SequenceCompareTo(y.AsSpan()) * _direction; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about submitting the changes in this first in another PR?
Perhaps this can be discussed faster and merged quicker.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe something like
public int Compare(byte[]? x, byte[]? y)
{
if (ReferenceEquals(x, y)) return 0;
if (x is null) return y is null ? 0 : -_direction;
if (y is null) return _direction;
return _direction * x.AsSpan().SequenceCompareTo(y.AsSpan());
}
Is the length multiplication really needed?
byte[] a = new byte[10];
byte[] b = new byte[20];
ByteArrayComparer comparer = ByteArrayComparer.Default;
Console.WriteLine(comparer.Compare(null, a)); // Expected: -1, Original: -10
Console.WriteLine(comparer.Compare(null, b)); // Expected: -1, Original: -20
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Im sorry, I mean MemorySnapshot
was returning all results for null
.
@@ -547,7 +546,7 @@ public void TestBlockchain_ListContracts() | |||
Assert.AreEqual(state.Hash, NativeContract.ContractManagement.GetContract(engine.SnapshotCache, state.Hash).Hash); | |||
|
|||
var list2 = NativeContract.ContractManagement.ListContracts(engine.SnapshotCache); | |||
Assert.AreEqual(list.Count(), list2.Count()); | |||
Assert.AreEqual(list.Count(), list2.Count() - 1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why this changed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The test didn't change, this line was before
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was an issue with DataCache
being bugged. Let me find out what happening, so I can go into more detail about it.
@@ -290,7 +290,7 @@ public void TestFindRange() | |||
Assert.IsTrue(items[0].Value.EqualsTo(value5)); | |||
Assert.AreEqual(key4, items[1].Key); | |||
Assert.IsTrue(items[1].Value.EqualsTo(value4)); | |||
Assert.AreEqual(2, items.Length); | |||
Assert.AreEqual(3, items.Length); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why this changed, and not in the other PR?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because it from starting key to ending end. It's not in between. We don't skip the 1st one.
// OLD
FindRange([0x00, 0x00, 0x04], [0x00, 0x00, 0x03], Backwards);
// Results: Empty
// NEW
FindRange([0x00, 0x00, 0x04], [0x00, 0x00, 0x03], Backwards);
// Results:
// [0x00, 0x00, 0x04]
// [0x00, 0x00, 0x03]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you move this fix into the other pr, and here only the DataCache refactor?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't this part of the DataCache
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I rewrote all the code. So it would be hard for me to put back the bug
.
…8/neo into fix/datacache-store
Replace the name, and change the logic, makes harder the review, I reverted the name replacement, you can do it in the next pr (i'm not against to) but in the same PR, makes this review harder and slower. |
Description
Mostly bug fixes and same data results as the
Leveldb
andRocksdb
.Fixes # (issue)
Type of change
How Has This Been Tested?
Checklist: