mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-12 06:53:46 +00:00
Proof-of-concept test sync to solve colliding nonces
This commit is contained in:
parent
f9be9a2302
commit
3cc01553e5
1 changed files with 11 additions and 0 deletions
|
|
@ -25,6 +25,7 @@ import (
|
||||||
"math/big"
|
"math/big"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
"sync"
|
||||||
|
|
||||||
"github.com/ethereum/go-ethereum/accounts"
|
"github.com/ethereum/go-ethereum/accounts"
|
||||||
"github.com/ethereum/go-ethereum/accounts/keystore"
|
"github.com/ethereum/go-ethereum/accounts/keystore"
|
||||||
|
|
@ -1166,10 +1167,20 @@ func submitTransaction(ctx context.Context, b Backend, tx *types.Transaction) (c
|
||||||
}
|
}
|
||||||
return tx.Hash(), nil
|
return tx.Hash(), nil
|
||||||
}
|
}
|
||||||
|
var nonceMutex sync.RWMutex // global mutex for locking chain operations
|
||||||
|
|
||||||
|
|
||||||
// SendTransaction creates a transaction for the given argument, sign it and submit it to the
|
// SendTransaction creates a transaction for the given argument, sign it and submit it to the
|
||||||
// transaction pool.
|
// transaction pool.
|
||||||
func (s *PublicTransactionPoolAPI) SendTransaction(ctx context.Context, args SendTxArgs) (common.Hash, error) {
|
func (s *PublicTransactionPoolAPI) SendTransaction(ctx context.Context, args SendTxArgs) (common.Hash, error) {
|
||||||
|
|
||||||
|
if args.Nonce == nil {
|
||||||
|
// We'll need to set nonce from pool, and thus we need to lock here
|
||||||
|
nonceMutex.Lock()
|
||||||
|
defer nonceMutex.Unlock()
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
// Set some sanity defaults and terminate on failure
|
// Set some sanity defaults and terminate on failure
|
||||||
if err := args.setDefaults(ctx, s.b); err != nil {
|
if err := args.setDefaults(ctx, s.b); err != nil {
|
||||||
return common.Hash{}, err
|
return common.Hash{}, err
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue