-
Notifications
You must be signed in to change notification settings - Fork 549
Refactor CalculateValueHash for header #9276
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
base: master
Are you sure you want to change the base?
Conversation
if (rlpStreamDecoder is null) | ||
throw new RlpException($"Decoder not found for {typeof(T).Name}"); | ||
|
||
int totalLength = rlpStreamDecoder.GetLength(item, behaviors); |
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.
not used?
KeccakRlpStream stream = new(); | ||
IRlpStreamDecoder<T>? rlpStreamDecoder = GetStreamDecoder<T>(); | ||
if (rlpStreamDecoder is null) | ||
throw new RlpException($"Decoder not found for {typeof(T).Name}"); |
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.
Move to ThrowXXX method for performance
public static ValueHash256 EncodeForHash<T>(T item, RlpBehaviors behaviors = RlpBehaviors.None) | ||
{ | ||
KeccakRlpStream stream = new(); | ||
IRlpStreamDecoder<T>? rlpStreamDecoder = GetStreamDecoder<T>(); |
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.
bit of cost for every hash calculation, but we probably have to pay it
This reverts commit c987460.
This is an attempt to make hash calculation more dynamic, since header hash is done through an extension method and cannot be overridden.
An alternative could be to have a virtual method returning
ValueHash256
inBlockHeader
itself, and have it return null inBlockHeader
since the decoders doesn't live in Core namespace.