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 (
"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()

View File

@ -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 {

View File

@ -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

View File

@ -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()