-
Notifications
You must be signed in to change notification settings - Fork 245
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
feat: Add trace_get #987
feat: Add trace_get #987
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -50,6 +50,13 @@ where | |
hash: TxHash, | ||
) -> TransportResult<Vec<LocalizedTransactionTrace>>; | ||
|
||
/// Traces of the transaction on the given positions | ||
async fn trace_get( | ||
&self, | ||
hash: TxHash, | ||
index: u64, | ||
) -> TransportResult<LocalizedTransactionTrace>; | ||
|
||
/// Trace the given raw transaction. | ||
async fn trace_raw_transaction( | ||
&self, | ||
|
@@ -119,6 +126,15 @@ where | |
self.client().request("trace_transaction", (hash,)).await | ||
} | ||
|
||
async fn trace_get( | ||
&self, | ||
hash: TxHash, | ||
index: u64, | ||
) -> TransportResult<LocalizedTransactionTrace> { | ||
// We are using vec![indices] because API accepts a list, but in fact works only if list.len == 1 | ||
SozinM marked this conversation as resolved.
Show resolved
Hide resolved
|
||
self.client().request("trace_get", (hash, vec![index])).await | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. you can use tuples for lists in JSON since they're equivalent to avoid allocating on the heap, see above in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this should also use the |
||
} | ||
|
||
async fn trace_raw_transaction( | ||
&self, | ||
data: &[u8], | ||
|
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.
since this is an index, I wonder if we should use usize here because I assume most of the time this value is derived from doing some vec.len() +- ops
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.
That's a good point, put usize in there.
I think it would be less convenient to put Index as type because then all calls to trace_get would require a .into() call from the user. It probably would be less convenient.