Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

all: remove empty function SaveData() #774

Merged
merged 1 commit into from
Dec 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions XDCx/XDCx.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,6 @@ func (XDCx *XDCX) Start(server *p2p.Server) error {
return nil
}

func (XDCx *XDCX) SaveData() {
}
func (XDCx *XDCX) Stop() error {
return nil
}
Expand Down
3 changes: 0 additions & 3 deletions XDCxlending/XDCxlending.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,6 @@ func (l *Lending) Start(server *p2p.Server) error {
return nil
}

func (l *Lending) SaveData() {
}

func (l *Lending) Stop() error {
return nil
}
Expand Down
9 changes: 2 additions & 7 deletions core/blockchain.go
Original file line number Diff line number Diff line change
Expand Up @@ -922,12 +922,7 @@ func (bc *BlockChain) TrieNode(hash common.Hash) ([]byte, error) {
return bc.stateCache.TrieDB().Node(hash)
}

func (bc *BlockChain) SaveData() {
bc.wg.Add(1)
defer bc.wg.Done()
// Make sure no inconsistent state is leaked during insertion
bc.mu.Lock()
defer bc.mu.Unlock()
func (bc *BlockChain) saveData() {
// Ensure the state of a recent block is also stored to disk before exiting.
// We're writing three different states to catch different restart scenarios:
// - HEAD: So we don't need to reprocess any blocks in the general case
Expand Down Expand Up @@ -1011,7 +1006,7 @@ func (bc *BlockChain) Stop() {
close(bc.quit)
atomic.StoreInt32(&bc.procInterrupt, 1)
bc.wg.Wait()
bc.SaveData()
bc.saveData()
log.Info("Blockchain manager stopped")
}

Expand Down
4 changes: 0 additions & 4 deletions eth/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -557,10 +557,6 @@ func (e *Ethereum) Start(srvr *p2p.Server) error {
return nil
}

func (e *Ethereum) SaveData() {
e.blockchain.SaveData()
}

// Stop implements node.Service, terminating all internal goroutines used by the
// Ethereum protocol.
func (e *Ethereum) Stop() error {
Expand Down
2 changes: 0 additions & 2 deletions ethstats/ethstats.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,6 @@ func (s *Service) Start(server *p2p.Server) error {
log.Info("Stats daemon started")
return nil
}
func (s *Service) SaveData() {
}

// Stop implements node.Service, terminating the monitoring and reporting daemon.
func (s *Service) Stop() error {
Expand Down
4 changes: 0 additions & 4 deletions les/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -228,10 +228,6 @@ func (s *LightEthereum) Start(srvr *p2p.Server) error {
return nil
}

func (s *LightEthereum) SaveData() {
s.blockchain.SaveData()
}

// Stop implements node.Service, terminating all internal goroutines used by the
// Ethereum protocol.
func (s *LightEthereum) Stop() error {
Expand Down
3 changes: 0 additions & 3 deletions light/lightchain.go
Original file line number Diff line number Diff line change
Expand Up @@ -281,9 +281,6 @@ func (lc *LightChain) GetBlockByNumber(ctx context.Context, number uint64) (*typ
return lc.GetBlock(ctx, hash, number)
}

func (bc *LightChain) SaveData() {
}

// Stop stops the blockchain service. If any imports are currently in progress
// it will abort them using the procInterrupt.
func (lc *LightChain) Stop() {
Expand Down
3 changes: 0 additions & 3 deletions node/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -478,9 +478,6 @@ func (n *Node) Stop() error {
return ErrNodeStopped
}

for _, service := range n.services {
service.SaveData()
}
// Terminate the API, services and the p2p server.
n.stopWS()
n.stopHTTP()
Expand Down
1 change: 0 additions & 1 deletion node/node_example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ type SampleService struct{}
func (s *SampleService) Protocols() []p2p.Protocol { return nil }
func (s *SampleService) APIs() []rpc.API { return nil }
func (s *SampleService) Start(*p2p.Server) error { fmt.Println("Service starting..."); return nil }
func (s *SampleService) SaveData() {}
func (s *SampleService) Stop() error { fmt.Println("Service stopping..."); return nil }

func ExampleService() {
Expand Down
3 changes: 1 addition & 2 deletions node/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,7 @@ type Service interface {
// Start is called after all services have been constructed and the networking
// layer was also initialized to spawn any goroutines required by the service.
Start(server *p2p.Server) error
//Save data before stop
SaveData()

// Stop terminates all goroutines belonging to the service, blocking until they
// are all terminated.
Stop() error
Expand Down
4 changes: 1 addition & 3 deletions node/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ type NoopService struct{}
func (s *NoopService) Protocols() []p2p.Protocol { return nil }
func (s *NoopService) APIs() []rpc.API { return nil }
func (s *NoopService) Start(*p2p.Server) error { return nil }
func (s *NoopService) SaveData() {}
func (s *NoopService) Stop() error { return nil }

func NewNoopService(*ServiceContext) (Service, error) { return new(NoopService), nil }
Expand Down Expand Up @@ -79,8 +78,7 @@ func (s *InstrumentedService) Start(server *p2p.Server) error {
}
return s.start
}
func (s *InstrumentedService) SaveData() {
}

func (s *InstrumentedService) Stop() error {
if s.stopHook != nil {
s.stopHook()
Expand Down
2 changes: 0 additions & 2 deletions p2p/simulations/adapters/exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -504,8 +504,6 @@ func (s *snapshotService) Start(*p2p.Server) error {
return nil
}

func (s *snapshotService) SaveData() {
}
func (s *snapshotService) Stop() error {
return nil
}
Expand Down
3 changes: 0 additions & 3 deletions p2p/simulations/examples/ping-pong.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,6 @@ func (p *pingPongService) Start(server *p2p.Server) error {
return nil
}

func (p *pingPongService) SaveData() {
}

func (p *pingPongService) Stop() error {
p.log.Info("ping-pong service stopping")
return nil
Expand Down
2 changes: 0 additions & 2 deletions p2p/simulations/http_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,6 @@ func (t *testService) Start(server *p2p.Server) error {
return nil
}

func (t *testService) SaveData() {
}
func (t *testService) Stop() error {
return nil
}
Expand Down
6 changes: 0 additions & 6 deletions p2p/testing/protocoltester.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,9 +145,6 @@ func (tn *testNode) Start(server *p2p.Server) error {
return nil
}

func (tn *testNode) SaveData() {
}

func (tn *testNode) Stop() error {
return nil
}
Expand Down Expand Up @@ -201,9 +198,6 @@ func (mn *mockNode) Expect(exp ...Expect) error {
return <-mn.err
}

func (mn *mockNode) SaveData() {
}

func (mn *mockNode) Stop() error {
mn.stopOnce.Do(func() { close(mn.stop) })
return nil
Expand Down
Loading