Patch for concurrent iterator & others (onto v1.11.6) #386
@ -23,10 +23,9 @@ import (
|
|||||||
"math/big"
|
"math/big"
|
||||||
"math/rand"
|
"math/rand"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"os/signal"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/ethereum/go-ethereum/accounts/keystore"
|
|
||||||
"github.com/ethereum/go-ethereum/common"
|
"github.com/ethereum/go-ethereum/common"
|
||||||
"github.com/ethereum/go-ethereum/common/fdlimit"
|
"github.com/ethereum/go-ethereum/common/fdlimit"
|
||||||
"github.com/ethereum/go-ethereum/consensus/ethash"
|
"github.com/ethereum/go-ethereum/consensus/ethash"
|
||||||
@ -58,12 +57,17 @@ func main() {
|
|||||||
faucets[i], _ = crypto.GenerateKey()
|
faucets[i], _ = crypto.GenerateKey()
|
||||||
}
|
}
|
||||||
// Pre-generate the ethash mining DAG so we don't race
|
// Pre-generate the ethash mining DAG so we don't race
|
||||||
ethash.MakeDataset(1, filepath.Join(os.Getenv("HOME"), ".ethash"))
|
ethash.MakeDataset(1, ethconfig.Defaults.Ethash.DatasetDir)
|
||||||
|
|
||||||
// Create an Ethash network based off of the Ropsten config
|
// Create an Ethash network based off of the Ropsten config
|
||||||
genesis := makeGenesis(faucets)
|
genesis := makeGenesis(faucets)
|
||||||
|
|
||||||
|
// Handle interrupts.
|
||||||
|
interruptCh := make(chan os.Signal, 5)
|
||||||
|
signal.Notify(interruptCh, os.Interrupt)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
stacks []*node.Node
|
||||||
nodes []*eth.Ethereum
|
nodes []*eth.Ethereum
|
||||||
enodes []*enode.Node
|
enodes []*enode.Node
|
||||||
)
|
)
|
||||||
@ -85,12 +89,6 @@ func main() {
|
|||||||
// Start tracking the node and its enode
|
// Start tracking the node and its enode
|
||||||
nodes = append(nodes, ethBackend)
|
nodes = append(nodes, ethBackend)
|
||||||
enodes = append(enodes, stack.Server().Self())
|
enodes = append(enodes, stack.Server().Self())
|
||||||
|
|
||||||
// Inject the signer key and start sealing with it
|
|
||||||
store := stack.AccountManager().Backends(keystore.KeyStoreType)[0].(*keystore.KeyStore)
|
|
||||||
if _, err := store.NewAccount(""); err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Iterate over all the nodes and start mining
|
// Iterate over all the nodes and start mining
|
||||||
@ -111,6 +109,16 @@ func main() {
|
|||||||
signer = types.LatestSignerForChainID(genesis.Config.ChainID)
|
signer = types.LatestSignerForChainID(genesis.Config.ChainID)
|
||||||
)
|
)
|
||||||
for {
|
for {
|
||||||
|
// Stop when interrupted.
|
||||||
|
select {
|
||||||
|
case <-interruptCh:
|
||||||
|
for _, node := range stacks {
|
||||||
|
node.Close()
|
||||||
|
}
|
||||||
|
return
|
||||||
|
default:
|
||||||
|
}
|
||||||
|
|
||||||
// Pick a random mining node
|
// Pick a random mining node
|
||||||
index := rand.Intn(len(faucets))
|
index := rand.Intn(len(faucets))
|
||||||
backend := nodes[index%len(nodes)]
|
backend := nodes[index%len(nodes)]
|
||||||
@ -242,6 +250,7 @@ func makeMiner(genesis *core.Genesis) (*node.Node, *eth.Ethereum, error) {
|
|||||||
GPO: ethconfig.Defaults.GPO,
|
GPO: ethconfig.Defaults.GPO,
|
||||||
Ethash: ethconfig.Defaults.Ethash,
|
Ethash: ethconfig.Defaults.Ethash,
|
||||||
Miner: miner.Config{
|
Miner: miner.Config{
|
||||||
|
Etherbase: common.Address{1},
|
||||||
GasCeil: genesis.GasLimit * 11 / 10,
|
GasCeil: genesis.GasLimit * 11 / 10,
|
||||||
GasPrice: big.NewInt(1),
|
GasPrice: big.NewInt(1),
|
||||||
Recommit: time.Second,
|
Recommit: time.Second,
|
||||||
|
@ -24,6 +24,7 @@ import (
|
|||||||
"math/big"
|
"math/big"
|
||||||
"math/rand"
|
"math/rand"
|
||||||
"os"
|
"os"
|
||||||
|
"os/signal"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/ethereum/go-ethereum/accounts/keystore"
|
"github.com/ethereum/go-ethereum/accounts/keystore"
|
||||||
@ -59,11 +60,15 @@ func main() {
|
|||||||
// Create a Clique network based off of the Rinkeby config
|
// Create a Clique network based off of the Rinkeby config
|
||||||
genesis := makeGenesis(faucets, sealers)
|
genesis := makeGenesis(faucets, sealers)
|
||||||
|
|
||||||
|
// Handle interrupts.
|
||||||
|
interruptCh := make(chan os.Signal, 5)
|
||||||
|
signal.Notify(interruptCh, os.Interrupt)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
stacks []*node.Node
|
||||||
nodes []*eth.Ethereum
|
nodes []*eth.Ethereum
|
||||||
enodes []*enode.Node
|
enodes []*enode.Node
|
||||||
)
|
)
|
||||||
|
|
||||||
for _, sealer := range sealers {
|
for _, sealer := range sealers {
|
||||||
// Start the node and wait until it's up
|
// Start the node and wait until it's up
|
||||||
stack, ethBackend, err := makeSealer(genesis)
|
stack, ethBackend, err := makeSealer(genesis)
|
||||||
@ -80,18 +85,20 @@ func main() {
|
|||||||
stack.Server().AddPeer(n)
|
stack.Server().AddPeer(n)
|
||||||
}
|
}
|
||||||
// Start tracking the node and its enode
|
// Start tracking the node and its enode
|
||||||
|
stacks = append(stacks, stack)
|
||||||
nodes = append(nodes, ethBackend)
|
nodes = append(nodes, ethBackend)
|
||||||
enodes = append(enodes, stack.Server().Self())
|
enodes = append(enodes, stack.Server().Self())
|
||||||
|
|
||||||
// Inject the signer key and start sealing with it
|
// Inject the signer key and start sealing with it
|
||||||
store := stack.AccountManager().Backends(keystore.KeyStoreType)[0].(*keystore.KeyStore)
|
ks := keystore.NewKeyStore(stack.KeyStoreDir(), keystore.LightScryptN, keystore.LightScryptP)
|
||||||
signer, err := store.ImportECDSA(sealer, "")
|
signer, err := ks.ImportECDSA(sealer, "")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
if err := store.Unlock(signer, ""); err != nil {
|
if err := ks.Unlock(signer, ""); err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
stack.AccountManager().AddBackend(ks)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Iterate over all the nodes and start signing on them
|
// Iterate over all the nodes and start signing on them
|
||||||
@ -106,6 +113,16 @@ func main() {
|
|||||||
// Start injecting transactions from the faucet like crazy
|
// Start injecting transactions from the faucet like crazy
|
||||||
nonces := make([]uint64, len(faucets))
|
nonces := make([]uint64, len(faucets))
|
||||||
for {
|
for {
|
||||||
|
// Stop when interrupted.
|
||||||
|
select {
|
||||||
|
case <-interruptCh:
|
||||||
|
for _, node := range stacks {
|
||||||
|
node.Close()
|
||||||
|
}
|
||||||
|
return
|
||||||
|
default:
|
||||||
|
}
|
||||||
|
|
||||||
// Pick a random signer node
|
// Pick a random signer node
|
||||||
index := rand.Intn(len(faucets))
|
index := rand.Intn(len(faucets))
|
||||||
backend := nodes[index%len(nodes)]
|
backend := nodes[index%len(nodes)]
|
||||||
|
@ -23,10 +23,9 @@ import (
|
|||||||
"math/big"
|
"math/big"
|
||||||
"math/rand"
|
"math/rand"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"os/signal"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/ethereum/go-ethereum/accounts/keystore"
|
|
||||||
"github.com/ethereum/go-ethereum/common"
|
"github.com/ethereum/go-ethereum/common"
|
||||||
"github.com/ethereum/go-ethereum/common/fdlimit"
|
"github.com/ethereum/go-ethereum/common/fdlimit"
|
||||||
"github.com/ethereum/go-ethereum/consensus/ethash"
|
"github.com/ethereum/go-ethereum/consensus/ethash"
|
||||||
@ -54,12 +53,17 @@ func main() {
|
|||||||
faucets[i], _ = crypto.GenerateKey()
|
faucets[i], _ = crypto.GenerateKey()
|
||||||
}
|
}
|
||||||
// Pre-generate the ethash mining DAG so we don't race
|
// Pre-generate the ethash mining DAG so we don't race
|
||||||
ethash.MakeDataset(1, filepath.Join(os.Getenv("HOME"), ".ethash"))
|
ethash.MakeDataset(1, ethconfig.Defaults.Ethash.DatasetDir)
|
||||||
|
|
||||||
// Create an Ethash network based off of the Ropsten config
|
// Create an Ethash network based off of the Ropsten config
|
||||||
genesis := makeGenesis(faucets)
|
genesis := makeGenesis(faucets)
|
||||||
|
|
||||||
|
// Handle interrupts.
|
||||||
|
interruptCh := make(chan os.Signal, 5)
|
||||||
|
signal.Notify(interruptCh, os.Interrupt)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
stacks []*node.Node
|
||||||
nodes []*eth.Ethereum
|
nodes []*eth.Ethereum
|
||||||
enodes []*enode.Node
|
enodes []*enode.Node
|
||||||
)
|
)
|
||||||
@ -79,14 +83,9 @@ func main() {
|
|||||||
stack.Server().AddPeer(n)
|
stack.Server().AddPeer(n)
|
||||||
}
|
}
|
||||||
// Start tracking the node and its enode
|
// Start tracking the node and its enode
|
||||||
|
stacks = append(stacks, stack)
|
||||||
nodes = append(nodes, ethBackend)
|
nodes = append(nodes, ethBackend)
|
||||||
enodes = append(enodes, stack.Server().Self())
|
enodes = append(enodes, stack.Server().Self())
|
||||||
|
|
||||||
// Inject the signer key and start sealing with it
|
|
||||||
store := stack.AccountManager().Backends(keystore.KeyStoreType)[0].(*keystore.KeyStore)
|
|
||||||
if _, err := store.NewAccount(""); err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Iterate over all the nodes and start mining
|
// Iterate over all the nodes and start mining
|
||||||
@ -101,6 +100,16 @@ func main() {
|
|||||||
// Start injecting transactions from the faucets like crazy
|
// Start injecting transactions from the faucets like crazy
|
||||||
nonces := make([]uint64, len(faucets))
|
nonces := make([]uint64, len(faucets))
|
||||||
for {
|
for {
|
||||||
|
// Stop when interrupted.
|
||||||
|
select {
|
||||||
|
case <-interruptCh:
|
||||||
|
for _, node := range stacks {
|
||||||
|
node.Close()
|
||||||
|
}
|
||||||
|
return
|
||||||
|
default:
|
||||||
|
}
|
||||||
|
|
||||||
// Pick a random mining node
|
// Pick a random mining node
|
||||||
index := rand.Intn(len(faucets))
|
index := rand.Intn(len(faucets))
|
||||||
backend := nodes[index%len(nodes)]
|
backend := nodes[index%len(nodes)]
|
||||||
@ -171,6 +180,7 @@ func makeMiner(genesis *core.Genesis) (*node.Node, *eth.Ethereum, error) {
|
|||||||
GPO: ethconfig.Defaults.GPO,
|
GPO: ethconfig.Defaults.GPO,
|
||||||
Ethash: ethconfig.Defaults.Ethash,
|
Ethash: ethconfig.Defaults.Ethash,
|
||||||
Miner: miner.Config{
|
Miner: miner.Config{
|
||||||
|
Etherbase: common.Address{1},
|
||||||
GasCeil: genesis.GasLimit * 11 / 10,
|
GasCeil: genesis.GasLimit * 11 / 10,
|
||||||
GasPrice: big.NewInt(1),
|
GasPrice: big.NewInt(1),
|
||||||
Recommit: time.Second,
|
Recommit: time.Second,
|
||||||
|
Loading…
Reference in New Issue
Block a user