From b652768241ee5cd6fc917ce536da70cf640daf1e Mon Sep 17 00:00:00 2001 From: ledgerwatch Date: Sun, 4 Oct 2020 17:18:06 +0100 Subject: [PATCH] Revert "pass_root_ctx_to_p2p_server (#1179)" (#1182) This reverts commit b8c38802544f500bdc9d75515bfebb0153a2d5de. --- cmd/tg/main.go | 17 +++++------------ node/node.go | 5 ----- p2p/server.go | 4 ---- turbo/node/node.go | 5 ----- 4 files changed, 5 insertions(+), 26 deletions(-) diff --git a/cmd/tg/main.go b/cmd/tg/main.go index 3cb6d1923..87ff20b18 100644 --- a/cmd/tg/main.go +++ b/cmd/tg/main.go @@ -2,14 +2,14 @@ package main import ( "fmt" - "net" "os" - "github.com/ledgerwatch/turbo-geth/cmd/utils" "github.com/ledgerwatch/turbo-geth/eth/stagedsync" "github.com/ledgerwatch/turbo-geth/log" - turbocli "github.com/ledgerwatch/turbo-geth/turbo/cli" "github.com/ledgerwatch/turbo-geth/turbo/node" + + turbocli "github.com/ledgerwatch/turbo-geth/turbo/cli" + "github.com/urfave/cli" ) @@ -26,22 +26,15 @@ func main() { os.Exit(1) } } - -func runTurboGeth(cliCtx *cli.Context) { +func runTurboGeth(ctx *cli.Context) { // creating staged sync with all default parameters sync := stagedsync.New( stagedsync.DefaultStages(), stagedsync.DefaultUnwindOrder(), ) - ctx := utils.RootContext() - // initializing the node and providing the current git commit there - tg := node.New(cliCtx, sync, node.Params{GitCommit: gitCommit}) - tg.SetP2PListenFunc(func(network, addr string) (net.Listener, error) { - var lc net.ListenConfig - return lc.Listen(ctx, network, addr) - }) + tg := node.New(ctx, sync, node.Params{GitCommit: gitCommit}) // running the node err := tg.Serve() diff --git a/node/node.go b/node/node.go index 86ee9a155..08e7e4580 100644 --- a/node/node.go +++ b/node/node.go @@ -19,7 +19,6 @@ package node import ( "errors" "fmt" - "net" "net/http" "os" "path/filepath" @@ -143,10 +142,6 @@ func New(conf *Config) (*Node, error) { return node, nil } -func (n *Node) SetP2PListenFunc(listenFunc func(network, addr string) (net.Listener, error)) { - n.server.SetP2PListenFunc(listenFunc) -} - // Start starts all registered lifecycles, RPC services and p2p networking. // Node can only be started once. func (n *Node) Start() error { diff --git a/p2p/server.go b/p2p/server.go index a8631ce58..69418c291 100644 --- a/p2p/server.go +++ b/p2p/server.go @@ -314,10 +314,6 @@ func (srv *Server) Peers() []*Peer { return ps } -func (srv *Server) SetP2PListenFunc(listenFunc func(network, addr string) (net.Listener, error)) { - srv.listenFunc = listenFunc -} - // PeerCount returns the number of connected peers. func (srv *Server) PeerCount() int { var count int diff --git a/turbo/node/node.go b/turbo/node/node.go index c07466edf..ef5b82718 100644 --- a/turbo/node/node.go +++ b/turbo/node/node.go @@ -3,7 +3,6 @@ package node import ( "math" - "net" "runtime/debug" "strconv" "time" @@ -29,10 +28,6 @@ type TurboGethNode struct { backend *eth.Ethereum } -func (tg *TurboGethNode) SetP2PListenFunc(listenFunc func(network, addr string) (net.Listener, error)) { - tg.stack.SetP2PListenFunc(listenFunc) -} - // Serve runs the node and blocks the execution. It returns when the node is existed. func (tg *TurboGethNode) Serve() error { defer tg.stack.Close()