custom nonce
This commit is contained in:
parent
9814a9a5e7
commit
a4195e5b5c
|
@ -240,7 +240,7 @@ func (t *Transactor) validateAndPropagate(selectedAccount *account.SelectedExtKe
|
||||||
defer func() {
|
defer func() {
|
||||||
// nonce should be incremented only if tx completed without error
|
// nonce should be incremented only if tx completed without error
|
||||||
// if upstream node returned nonce higher than ours we will stick to it
|
// 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.localNonce.Store(args.From, nonce+1)
|
||||||
}
|
}
|
||||||
t.addrLock.UnlockAddr(args.From)
|
t.addrLock.UnlockAddr(args.From)
|
||||||
|
@ -248,14 +248,20 @@ func (t *Transactor) validateAndPropagate(selectedAccount *account.SelectedExtKe
|
||||||
}()
|
}()
|
||||||
ctx, cancel := context.WithTimeout(context.Background(), t.rpcCallTimeout)
|
ctx, cancel := context.WithTimeout(context.Background(), t.rpcCallTimeout)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
nonce, err = t.pendingNonceProvider.PendingNonceAt(ctx, common.Address(args.From))
|
|
||||||
if err != nil {
|
if args.Nonce == nil {
|
||||||
return hash, err
|
|
||||||
}
|
nonce, err = t.pendingNonceProvider.PendingNonceAt(ctx, common.Address(args.From))
|
||||||
// if upstream node returned nonce higher than ours we will use it, as it probably means
|
if err != nil {
|
||||||
// that another client was used for sending transactions
|
return hash, err
|
||||||
if localNonce > nonce {
|
}
|
||||||
nonce = localNonce
|
// 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)
|
gasPrice := (*big.Int)(args.GasPrice)
|
||||||
if args.GasPrice == nil {
|
if args.GasPrice == nil {
|
||||||
|
|
Loading…
Reference in New Issue