mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-11 22:43:47 +00:00
swarm/network: Support disabling discovery for overlay sim
Signed-off-by: Lewis Marshall <lewis@lmars.net>
This commit is contained in:
parent
74d40d67b0
commit
fc904b482c
1 changed files with 6 additions and 0 deletions
|
|
@ -6,6 +6,7 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
"math/rand"
|
"math/rand"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
@ -22,6 +23,8 @@ import (
|
||||||
"github.com/ethereum/go-ethereum/swarm/network"
|
"github.com/ethereum/go-ethereum/swarm/network"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var noDiscovery = flag.Bool("no-discovery", false, "disable discovery (useful if you want to load a snapshot)")
|
||||||
|
|
||||||
type Simulation struct {
|
type Simulation struct {
|
||||||
mtx sync.Mutex
|
mtx sync.Mutex
|
||||||
stores map[discover.NodeID]*adapters.SimStateStore
|
stores map[discover.NodeID]*adapters.SimStateStore
|
||||||
|
|
@ -57,6 +60,7 @@ func (s *Simulation) NewService(ctx *adapters.ServiceContext) (node.Service, err
|
||||||
ticker := time.NewTicker(time.Duration(kad.PruneInterval) * time.Millisecond)
|
ticker := time.NewTicker(time.Duration(kad.PruneInterval) * time.Millisecond)
|
||||||
kad.Prune(ticker.C)
|
kad.Prune(ticker.C)
|
||||||
hp := network.NewHiveParams()
|
hp := network.NewHiveParams()
|
||||||
|
hp.Discovery = !*noDiscovery
|
||||||
hp.KeepAliveInterval = 3 * time.Second
|
hp.KeepAliveInterval = 3 * time.Second
|
||||||
|
|
||||||
config := &network.BzzConfig{
|
config := &network.BzzConfig{
|
||||||
|
|
@ -192,6 +196,8 @@ func startStopMocker(net *simulations.Network) {
|
||||||
|
|
||||||
// var server
|
// var server
|
||||||
func main() {
|
func main() {
|
||||||
|
flag.Parse()
|
||||||
|
|
||||||
runtime.GOMAXPROCS(runtime.NumCPU())
|
runtime.GOMAXPROCS(runtime.NumCPU())
|
||||||
|
|
||||||
log.Root().SetHandler(log.LvlFilterHandler(log.LvlDebug, log.StreamHandler(os.Stderr, log.TerminalFormat(false))))
|
log.Root().SetHandler(log.LvlFilterHandler(log.LvlDebug, log.StreamHandler(os.Stderr, log.TerminalFormat(false))))
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue