-
Notifications
You must be signed in to change notification settings - Fork 197
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
Last nonce in pool for sender endpoint #4232
Conversation
senderShard := atp.shardCoordinator.ComputeId(senderAddr) | ||
lastNonce, found := atp.fetchLastNonceForSender(string(senderAddr), senderShard) | ||
if !found { | ||
return 0, ErrCannotRetrieveNonce |
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.
if the sender doesn't have any tx in pool, is it an error? I don't think so. maybe treat this case and return "no transaction in pool for sender".. "cannot retrieve nonce" is not explanatory
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
return 0, ok | ||
} | ||
|
||
return lastTx.Tx.GetNonce(), ok |
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.
are the transactions in order by nonce? if no, this code doesn't cover all the situations.
If I send txs with nonces 1, 2, 3, 4, 7, 6, 5 in this order. will you code return 7 or 5 ?
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.
the structure that holds the txs by sender keeps them sorted by nonce.. this unittest should cover exactly this situation, where lastNonce
is added before nonce 1
Codecov Report
@@ Coverage Diff @@
## feat/new-tx-api #4232 +/- ##
================================================
Coverage 75.87% 75.87%
================================================
Files 645 645
Lines 85294 85366 +72
================================================
+ Hits 64713 64768 +55
- Misses 15785 15796 +11
- Partials 4796 4802 +6
Continue to review full report at Codecov.
|
Changes
/pool/by-sender/last-nonce/:sender
for the last nonce in tx pool for senderapiTransactionProcessor.go
in order to reduce duplicate codeIn order to test the changes, the following steps are needed:
elrond-txgen-go
and update the following:cmd/txgen/config/config.toml
, leaveScenarios = ["badNonce"]
, updateProxyServerURL
with the port that your local proxy uses, optional updateMintingValue
to a smaller onenode/config/walletKey.pem
(local testnet) one of the private keys and paste it intocmd/txgen/config
./txgen --new-account --num-accounts 10
http://127.0.0.1:node-port/transaction/pool
to get tx poolhttp://127.0.0.1:node-port/transaction/your-hash
http://127.0.0.1:node-port/transaction/pool/by-sender/last-nonce/your-sender