node, p2p: move network config out of Server

This silences a go vet message about copying p2p.Server in package node.
This commit is contained in:
Felix Lange
2016-05-18 11:31:00 +02:00
parent c8a8ad97f7
commit 542b839ec7
4 changed files with 36 additions and 28 deletions

View File

@ -49,7 +49,7 @@ type Node struct {
datadir string // Path to the currently used data directory
eventmux *event.TypeMux // Event multiplexer used between the services of a stack
serverConfig *p2p.Server // Configuration of the underlying P2P networking layer
serverConfig p2p.Config
server *p2p.Server // Currently running P2P networking layer
serviceFuncs []ServiceConstructor // Service constructors (in dependency order)
@ -97,7 +97,7 @@ func New(conf *Config) (*Node, error) {
}
return &Node{
datadir: conf.DataDir,
serverConfig: &p2p.Server{
serverConfig: p2p.Config{
PrivateKey: conf.NodeKey(),
Name: conf.Name,
Discovery: !conf.NoDiscovery,
@ -151,9 +151,7 @@ func (n *Node) Start() error {
return ErrNodeRunning
}
// Otherwise copy and specialize the P2P configuration
running := new(p2p.Server)
*running = *n.serverConfig
running := &p2p.Server{Config: n.serverConfig}
services := make(map[reflect.Type]Service)
for _, constructor := range n.serviceFuncs {
// Create a new context for the particular service