Skip to content
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

new core-go #465

Open
wants to merge 3 commits into
base: rc/v1.7.next1
Choose a base branch
from
Open

new core-go #465

wants to merge 3 commits into from

Conversation

sstanculeanu
Copy link
Contributor

No description provided.

@sstanculeanu sstanculeanu self-assigned this Oct 10, 2024
AdoAdoAdo
AdoAdoAdo previously approved these changes Oct 10, 2024
andreibancioiu
andreibancioiu previously approved these changes Oct 10, 2024
README.md Outdated
@@ -35,6 +35,7 @@ For more details, go [here](https://docs.multiversx.com/sdk-and-tools/proxy/).
- `/v1.0/transaction/cost` (POST) --> receives a single transaction in JSON format and returns it's cost
- `/v1.0/transaction/:txHash` (GET) --> returns the transaction which corresponds to the hash
- `/v1.0/transaction/:txHash?withResults=true` (GET) --> returns the transaction and results which correspond to the hash
- `/v1.0/transaction/:txHash?withResults=true&withRelayedTxHash=:relayedTxHash` (GET) --> returns the inner transaction which corresponds to the hash and was part of the relayedTxHash
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Without the suffix with (since, currently, we use with to dictate whether something has to be included in the response).

@@ -49,6 +49,8 @@ const (
UrlParameterWithAlteredAccounts = "withAlteredAccounts"
// UrlParameterWithKeys represents the name of an URL parameter
UrlParameterWithKeys = "withKeys"
// UrlParameterWithRelayedTxHash represents the name of an URL parameter
UrlParameterWithRelayedTxHash = "withRelayedTxHash"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Without the with prefix. This new parameter is closer (in meaning) to hintEpoch than to withTxs.

Comment on lines 434 to 452
func isResultOfInnerTx(allScrs []*transaction.ApiSmartContractResult, currentScr *transaction.ApiSmartContractResult, innerTxHash string) bool {
if currentScr.PrevTxHash == innerTxHash {
return true
}

parentScr := getParentSCR(allScrs, currentScr.PrevTxHash)
if check.IfNilReflect(parentScr) {
return false
}

return isResultOfInnerTx(allScrs, parentScr, innerTxHash)
}

func getParentSCR(allScrs []*transaction.ApiSmartContractResult, hash string) *transaction.ApiSmartContractResult {
for _, scr := range allScrs {
if scr.Hash == hash {
return scr
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

currentScr is used for its PrevTxHash only. Thus, an optimization would be to hold a map of [previous hash] to [hash]. This way, the repeated loops can be omitted. However, in practice, the optimization would only be marginal. Thus, all right as it is now, as well 👍

return isResultOfInnerTx(allScrs, parentScr, innerTxHash)
}

func getParentSCR(allScrs []*transaction.ApiSmartContractResult, hash string) *transaction.ApiSmartContractResult {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe can be named findSCRByHash().

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants