-
Notifications
You must be signed in to change notification settings - Fork 204
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
Added missing fields on the transaction/pool by-sender request #6039
Added missing fields on the transaction/pool by-sender request #6039
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## rc/v1.7.next1 #6039 +/- ##
=================================================
+ Coverage 79.88% 79.93% +0.04%
=================================================
Files 731 731
Lines 96234 96250 +16
=================================================
+ Hits 76874 76934 +60
+ Misses 13966 13927 -39
+ Partials 5394 5389 -5 ☔ View full report in Codecov by Sentry. |
} | ||
return ph | ||
} | ||
|
||
func shouldConsiderField(parametersMap map[string]struct{}, field string) bool { | ||
_, has := parametersMap[field] |
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.
slight optimization:
_, hasWildCard := parametersMap[wildCard]
if hasWildCard {
return true
}
_, has := parametersMap[field]
return has
return tx | ||
} | ||
|
||
func (atp *apiTransactionProcessor) getFieldGettersForTx(wrappedTx *txcache.WrappedTransaction) map[string]func() interface{} { |
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 is sub-optimal. Working with function pointers is also a little bit messy.
Why not further simplify?
func (atp *apiTransactionProcessor) extractRequestedTxInfo(wrappedTx *txcache.WrappedTransaction, requestedFieldsHandler fieldsHandler) common.Transaction {
fieldGetters := atp.getFieldGettersForTx(wrappedTx)
tx := common.Transaction{
TxFields: make(map[string]interface{}),
}
for field, value := range fieldGetters {
if requestedFieldsHandler.IsFieldSet(field) {
tx.TxFields[field] = value
}
}
return tx
}
func (atp *apiTransactionProcessor) getFieldGettersForTx(wrappedTx *txcache.WrappedTransaction) map[string]interface{} {
var fieldGetters = map[string]interface{}{
hashField: hex.EncodeToString(wrappedTx.TxHash),
nonceField: wrappedTx.Tx.GetNonce(),
senderField: atp.addressPubKeyConverter.SilentEncode(wrappedTx.Tx.GetSndAddr(), log),
receiverField: atp.addressPubKeyConverter.SilentEncode(wrappedTx.Tx.GetRcvAddr(), log),
gasLimitField: wrappedTx.Tx.GetGasLimit(),
gasPriceField: wrappedTx.Tx.GetGasPrice(),
rcvUsernameField: wrappedTx.Tx.GetRcvUserName(),
dataField: wrappedTx.Tx.GetData(),
valueField: getTxValue(wrappedTx),
senderShardID: wrappedTx.SenderShardID,
receiverShardID: wrappedTx.ReceiverShardID,
}
guardedTx, isGuardedTx := wrappedTx.Tx.(data.GuardedTransactionHandler)
if isGuardedTx {
fieldGetters[signatureField] = hex.EncodeToString(guardedTx.GetSignature())
fieldGetters[guardianField] = atp.addressPubKeyConverter.SilentEncode(guardedTx.GetGuardianAddr(), log)
fieldGetters[guardianSignatureField] = hex.EncodeToString(guardedTx.GetGuardianSignature())
}
return fieldGetters
}
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.
pushed
Reasoning behind the pull request
Proposed changes
guardian
,guardiansignature
,signature
,sendershard
,receivershard
and wildcard*
which will return all fields as in the next pictureTesting procedure
/transaction/pool?by-sender=erd1....&fields=
with the new fields.Pre-requisites
Based on the Contributing Guidelines the PR author and the reviewers must check the following requirements are met:
feat
branch created?feat
branch merging, do all satellite projects have a proper tag insidego.mod
?