Skip to content

Commit

Permalink
Update nonce if needed
Browse files Browse the repository at this point in the history
  • Loading branch information
ineiti committed Feb 28, 2024
1 parent 0c37fa9 commit 4187566
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions core/txn/signed/signed.go
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,17 @@ func (mgr *TransactionManager) Make(args ...txn.Arg) (txn.Transaction, error) {

opts = append(opts, WithHashFactory(mgr.hashFac))

nonce, err := mgr.client.GetNonce(mgr.signer.GetPublicKey())
if err != nil {
dela.Logger.Err(err).Msg("Couldn't update nonce")
}
// Only update our nonce if the stored nonce is bigger than ours.
// This allows to have transactions in the pool which are not yet accepted,
// but still have the correct nonce.
if nonce > mgr.nonce {
mgr.nonce = nonce
}

tx, err := NewTransaction(mgr.nonce, mgr.signer.GetPublicKey(), opts...)
if err != nil {
return nil, xerrors.Errorf("failed to create tx: %v", err)
Expand Down

0 comments on commit 4187566

Please sign in to comment.