mirror of
https://gitlab.com/pulsechaincom/erigon-pulse.git
synced 2024-12-21 19:20:39 +00:00
Remove unused code from Node struct (#6978)
The server attribute was only still used in a broken, skipped unit test which we may rewrite later
This commit is contained in:
parent
8ab3be0d5d
commit
a0ffa454ec
16
node/node.go
16
node/node.go
@ -20,7 +20,6 @@ import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"net"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"reflect"
|
||||
@ -37,7 +36,6 @@ import (
|
||||
"github.com/ledgerwatch/erigon-lib/kv/mdbx"
|
||||
"github.com/ledgerwatch/erigon-lib/kv/memdb"
|
||||
"github.com/ledgerwatch/erigon/migrations"
|
||||
"github.com/ledgerwatch/erigon/p2p"
|
||||
"github.com/ledgerwatch/log/v3"
|
||||
)
|
||||
|
||||
@ -47,7 +45,6 @@ type Node struct {
|
||||
log log.Logger
|
||||
dirLock *flock.Flock // prevents concurrent use of instance directory
|
||||
stop chan struct{} // Channel to wait for termination notifications
|
||||
server *p2p.Server // Currently running P2P networking layer
|
||||
startStopLock sync.Mutex // Start/Stop are protected by an additional lock
|
||||
state int // Tracks state of node lifecycle
|
||||
|
||||
@ -97,9 +94,6 @@ func New(conf *nodecfg.Config) (*Node, error) {
|
||||
return node, nil
|
||||
}
|
||||
|
||||
func (n *Node) SetP2PListenFunc(listenFunc func(network, addr string) (net.Listener, error)) {
|
||||
}
|
||||
|
||||
// Start starts all registered lifecycles, RPC services and p2p networking.
|
||||
// Node can only be started once.
|
||||
func (n *Node) Start() error {
|
||||
@ -280,16 +274,6 @@ func (n *Node) RegisterLifecycle(lifecycle Lifecycle) {
|
||||
n.lifecycles = append(n.lifecycles, lifecycle)
|
||||
}
|
||||
|
||||
// RegisterProtocols adds backend's protocols to the node's p2p server.
|
||||
func (n *Node) RegisterProtocols(protocols []p2p.Protocol) {
|
||||
n.lock.Lock()
|
||||
defer n.lock.Unlock()
|
||||
|
||||
if n.state != initializingState {
|
||||
panic("can't register protocols on running/stopped node")
|
||||
}
|
||||
}
|
||||
|
||||
// Config returns the configuration of node.
|
||||
func (n *Node) Config() *nodecfg.Config {
|
||||
return n.config
|
||||
|
@ -134,23 +134,7 @@ func TestLifecycleRegistry_Successful(t *testing.T) {
|
||||
// Tests whether a service's protocols can be registered properly on the node's p2p server.
|
||||
func TestRegisterProtocols(t *testing.T) {
|
||||
t.Skip("adjust to p2p sentry")
|
||||
stack, err := New(testNodeConfig(t))
|
||||
if err != nil {
|
||||
t.Fatalf("failed to create protocol stack: %v", err)
|
||||
}
|
||||
defer stack.Close()
|
||||
|
||||
fs, err := NewFullService(stack)
|
||||
if err != nil {
|
||||
t.Fatalf("could not create full service: %v", err)
|
||||
}
|
||||
|
||||
for _, protocol := range fs.Protocols() {
|
||||
if !containsProtocol(stack.server.Protocols, protocol) {
|
||||
t.Fatalf("protocol %v was not successfully registered", protocol)
|
||||
}
|
||||
}
|
||||
|
||||
// TODO
|
||||
}
|
||||
|
||||
// This test checks that open databases are closed with node.
|
||||
@ -404,9 +388,6 @@ func TestLifecycleTerminationGuarantee(t *testing.T) {
|
||||
delete(started, id)
|
||||
delete(stopped, id)
|
||||
}
|
||||
|
||||
stack.server = &p2p.Server{}
|
||||
stack.server.PrivateKey = testNodeKey
|
||||
}
|
||||
|
||||
func containsProtocol(stackProtocols []p2p.Protocol, protocol p2p.Protocol) bool {
|
||||
|
@ -19,10 +19,6 @@
|
||||
|
||||
package node
|
||||
|
||||
import (
|
||||
"github.com/ledgerwatch/erigon/p2p"
|
||||
)
|
||||
|
||||
// NoopLifecycle is a trivial implementation of the Service interface.
|
||||
type NoopLifecycle struct{}
|
||||
|
||||
@ -61,30 +57,3 @@ func (s *InstrumentedService) Stop() error {
|
||||
}
|
||||
return s.stop
|
||||
}
|
||||
|
||||
type FullService struct{}
|
||||
|
||||
func NewFullService(stack *Node) (*FullService, error) {
|
||||
fs := new(FullService)
|
||||
|
||||
stack.RegisterProtocols(fs.Protocols())
|
||||
stack.RegisterLifecycle(fs)
|
||||
return fs, nil
|
||||
}
|
||||
|
||||
func (f *FullService) Start() error { return nil }
|
||||
|
||||
func (f *FullService) Stop() error { return nil }
|
||||
|
||||
func (f *FullService) Protocols() []p2p.Protocol {
|
||||
return []p2p.Protocol{
|
||||
{
|
||||
Name: "test1",
|
||||
Version: uint(1),
|
||||
},
|
||||
{
|
||||
Name: "test2",
|
||||
Version: uint(2),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user