custom nonce

This commit is contained in:
andrey 2020-11-20 09:57:22 +01:00 committed by flexsurfer
parent 9814a9a5e7
commit a4195e5b5c
2 changed files with 16 additions and 10 deletions

View File

@ -1 +1 @@
0.63.11
0.63.12

View File

@ -240,7 +240,7 @@ func (t *Transactor) validateAndPropagate(selectedAccount *account.SelectedExtKe
defer func() {
// nonce should be incremented only if tx completed without error
// if upstream node returned nonce higher than ours we will stick to it
if err == nil {
if err == nil && args.Nonce == nil {
t.localNonce.Store(args.From, nonce+1)
}
t.addrLock.UnlockAddr(args.From)
@ -248,14 +248,20 @@ func (t *Transactor) validateAndPropagate(selectedAccount *account.SelectedExtKe
}()
ctx, cancel := context.WithTimeout(context.Background(), t.rpcCallTimeout)
defer cancel()
nonce, err = t.pendingNonceProvider.PendingNonceAt(ctx, common.Address(args.From))
if err != nil {
return hash, err
}
// if upstream node returned nonce higher than ours we will use it, as it probably means
// that another client was used for sending transactions
if localNonce > nonce {
nonce = localNonce
if args.Nonce == nil {
nonce, err = t.pendingNonceProvider.PendingNonceAt(ctx, common.Address(args.From))
if err != nil {
return hash, err
}
// if upstream node returned nonce higher than ours we will use it, as it probably means
// that another client was used for sending transactions
if localNonce > nonce {
nonce = localNonce
}
} else {
nonce = uint64(*args.Nonce)
}
gasPrice := (*big.Int)(args.GasPrice)
if args.GasPrice == nil {