-
Notifications
You must be signed in to change notification settings - Fork 596
Fix hive getLogs #9889
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
Open
deffrian
wants to merge
19
commits into
master
Choose a base branch
from
fix/get-logs
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+241
−252
Open
Fix hive getLogs #9889
Changes from 14 commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
c4bd767
try fix
deffrian 3ef1c5e
Fix tests
deffrian c0f2815
Try fix
deffrian 17a7c26
Fix
deffrian 882b207
Fix from & to
deffrian e1cc553
Fix block in the future
deffrian fbe0e23
Fix build
deffrian 05ae70f
Fix range in the future
deffrian 8782769
Fix block range
deffrian 4e9ee58
to
deffrian 001ed0e
Fix tests
deffrian 1ac7060
Fix json rpc tests
deffrian e36b6da
Fix formatting
deffrian 2f6dee6
Fix blockchain tests
deffrian 097b6b0
Fix suggestions
deffrian afd2a24
Fix tags
deffrian 845b607
Remove address from AddressFilter
deffrian dda4305
Fix tests
deffrian 28df9d8
Fix address filter
deffrian File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -124,7 +124,7 @@ public PendingTransactionFilter CreatePendingTransactionFilter(bool setId = true | |
| new(GetFilterId(setId)); | ||
|
|
||
| public LogFilter CreateLogFilter(BlockParameter fromBlock, BlockParameter toBlock, | ||
| object? address = null, IEnumerable<object?>? topics = null, bool setId = true) => | ||
| AddressAsKey[]? address = null, IEnumerable<Hash256[]?>? topics = null, bool setId = true) => | ||
| new(GetFilterId(setId), | ||
| fromBlock, | ||
| toBlock, | ||
|
|
@@ -165,7 +165,7 @@ private int GetFilterId(bool generateId) | |
| return 0; | ||
| } | ||
|
|
||
| private static TopicsFilter GetTopicsFilter(IEnumerable<object?>? topics = null) | ||
| private static TopicsFilter GetTopicsFilter(IEnumerable<Hash256[]?>? topics = null) | ||
| { | ||
| if (topics is null) | ||
| { | ||
|
|
@@ -202,48 +202,40 @@ private static TopicExpression GetTopicExpression(FilterTopic? filterTopic) | |
| return AnyTopic.Instance; | ||
| } | ||
|
|
||
| private static AddressFilter GetAddress(object? address) => | ||
| address switch | ||
| private static AddressFilter GetAddress(AddressAsKey[]? address) | ||
|
||
| { | ||
| if (address is null) | ||
| { | ||
| null => AddressFilter.AnyAddress, | ||
| string s => new AddressFilter(new Address(s)), | ||
| IEnumerable<string> e => new AddressFilter(e.Select(static a => new AddressAsKey(new Address(a))).ToHashSet()), | ||
| _ => throw new InvalidDataException("Invalid address filter format") | ||
| }; | ||
| return AddressFilter.AnyAddress; | ||
| } | ||
|
|
||
| private static FilterTopic?[]? GetFilterTopics(IEnumerable<object>? topics) => topics?.Select(GetTopic).ToArray(); | ||
| return new AddressFilter(address); | ||
| } | ||
|
|
||
| private static FilterTopic?[]? GetFilterTopics(IEnumerable<Hash256[]?>? topics) => topics?.Select(GetTopic).ToArray(); | ||
|
|
||
| private static FilterTopic? GetTopic(object? obj) | ||
| private static FilterTopic? GetTopic(Hash256[]? topics) | ||
| { | ||
| switch (obj) | ||
| if (topics?.Length == 1) | ||
| { | ||
| case null: | ||
| return null; | ||
| case string topic: | ||
| return new FilterTopic | ||
| { | ||
| Topic = new Hash256(topic) | ||
| }; | ||
| case Hash256 keccak: | ||
| return new FilterTopic | ||
| { | ||
| Topic = keccak | ||
| }; | ||
| return new FilterTopic | ||
| { | ||
| Topic = topics[0] | ||
| }; | ||
| } | ||
|
|
||
| return obj is not IEnumerable<string> topics | ||
| ? null | ||
| : new FilterTopic | ||
| else | ||
| { | ||
| return new FilterTopic() | ||
| { | ||
| Topics = topics.Select(static t => new Hash256(t)).ToArray() | ||
| Topics = topics | ||
| }; | ||
| } | ||
| } | ||
|
|
||
| private class FilterTopic | ||
| { | ||
| public Hash256? Topic { get; init; } | ||
| public Hash256[]? Topics { get; init; } | ||
|
|
||
| } | ||
|
|
||
| public void Dispose() | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 was the reason behind replacing
HashSetwith an array?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 think AddressFilter should decide how addresses are stored inside
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.
How about accepting
IEnumerableinstead? I see in some places we are callingToArrayto immediately follow withToHashSetafter.