Revert "pass_root_ctx_to_p2p_server (#1179)" (#1182)

This reverts commit b8c3880254.
This commit is contained in:
ledgerwatch 2020-10-04 17:18:06 +01:00 committed by GitHub
parent 55219d7ad3
commit b652768241
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 5 additions and 26 deletions

View File

@ -2,14 +2,14 @@ package main
import ( import (
"fmt" "fmt"
"net"
"os" "os"
"github.com/ledgerwatch/turbo-geth/cmd/utils"
"github.com/ledgerwatch/turbo-geth/eth/stagedsync" "github.com/ledgerwatch/turbo-geth/eth/stagedsync"
"github.com/ledgerwatch/turbo-geth/log" "github.com/ledgerwatch/turbo-geth/log"
turbocli "github.com/ledgerwatch/turbo-geth/turbo/cli"
"github.com/ledgerwatch/turbo-geth/turbo/node" "github.com/ledgerwatch/turbo-geth/turbo/node"
turbocli "github.com/ledgerwatch/turbo-geth/turbo/cli"
"github.com/urfave/cli" "github.com/urfave/cli"
) )
@ -26,22 +26,15 @@ func main() {
os.Exit(1) os.Exit(1)
} }
} }
func runTurboGeth(ctx *cli.Context) {
func runTurboGeth(cliCtx *cli.Context) {
// creating staged sync with all default parameters // creating staged sync with all default parameters
sync := stagedsync.New( sync := stagedsync.New(
stagedsync.DefaultStages(), stagedsync.DefaultStages(),
stagedsync.DefaultUnwindOrder(), stagedsync.DefaultUnwindOrder(),
) )
ctx := utils.RootContext()
// initializing the node and providing the current git commit there // initializing the node and providing the current git commit there
tg := node.New(cliCtx, sync, node.Params{GitCommit: gitCommit}) tg := node.New(ctx, sync, node.Params{GitCommit: gitCommit})
tg.SetP2PListenFunc(func(network, addr string) (net.Listener, error) {
var lc net.ListenConfig
return lc.Listen(ctx, network, addr)
})
// running the node // running the node
err := tg.Serve() err := tg.Serve()

View File

@ -19,7 +19,6 @@ package node
import ( import (
"errors" "errors"
"fmt" "fmt"
"net"
"net/http" "net/http"
"os" "os"
"path/filepath" "path/filepath"
@ -143,10 +142,6 @@ func New(conf *Config) (*Node, error) {
return node, nil 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. // Start starts all registered lifecycles, RPC services and p2p networking.
// Node can only be started once. // Node can only be started once.
func (n *Node) Start() error { func (n *Node) Start() error {

View File

@ -314,10 +314,6 @@ func (srv *Server) Peers() []*Peer {
return ps return ps
} }
func (srv *Server) SetP2PListenFunc(listenFunc func(network, addr string) (net.Listener, error)) {
srv.listenFunc = listenFunc
}
// PeerCount returns the number of connected peers. // PeerCount returns the number of connected peers.
func (srv *Server) PeerCount() int { func (srv *Server) PeerCount() int {
var count int var count int

View File

@ -3,7 +3,6 @@ package node
import ( import (
"math" "math"
"net"
"runtime/debug" "runtime/debug"
"strconv" "strconv"
"time" "time"
@ -29,10 +28,6 @@ type TurboGethNode struct {
backend *eth.Ethereum 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. // Serve runs the node and blocks the execution. It returns when the node is existed.
func (tg *TurboGethNode) Serve() error { func (tg *TurboGethNode) Serve() error {
defer tg.stack.Close() defer tg.stack.Close()