From 240757a1cea7dc70d0eeb4ed8f8e28c13fc373be Mon Sep 17 00:00:00 2001 From: Daniel Liu Date: Wed, 25 Dec 2024 09:16:01 +0800 Subject: [PATCH] all: remove empty function SaveData() --- XDCx/XDCx.go | 2 -- XDCxlending/XDCxlending.go | 3 --- core/blockchain.go | 9 ++------- eth/backend.go | 4 ---- ethstats/ethstats.go | 2 -- les/backend.go | 4 ---- light/lightchain.go | 3 --- node/node.go | 3 --- node/node_example_test.go | 1 - node/service.go | 3 +-- node/utils_test.go | 4 +--- p2p/simulations/adapters/exec.go | 2 -- p2p/simulations/examples/ping-pong.go | 3 --- p2p/simulations/http_test.go | 2 -- p2p/testing/protocoltester.go | 6 ------ 15 files changed, 4 insertions(+), 47 deletions(-) diff --git a/XDCx/XDCx.go b/XDCx/XDCx.go index 3fbaf0c783e2..fbb737240289 100644 --- a/XDCx/XDCx.go +++ b/XDCx/XDCx.go @@ -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 } diff --git a/XDCxlending/XDCxlending.go b/XDCxlending/XDCxlending.go index 1bf2496ff237..a1f8e9749fd1 100644 --- a/XDCxlending/XDCxlending.go +++ b/XDCxlending/XDCxlending.go @@ -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 } diff --git a/core/blockchain.go b/core/blockchain.go index 217e3be9e00a..48509e652057 100644 --- a/core/blockchain.go +++ b/core/blockchain.go @@ -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 @@ -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") } diff --git a/eth/backend.go b/eth/backend.go index b9cef04b11c8..6a3920dcc277 100644 --- a/eth/backend.go +++ b/eth/backend.go @@ -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 { diff --git a/ethstats/ethstats.go b/ethstats/ethstats.go index 4510478bb0e5..edcb255fbc03 100644 --- a/ethstats/ethstats.go +++ b/ethstats/ethstats.go @@ -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 { diff --git a/les/backend.go b/les/backend.go index 08933f93a0a4..e982603d2fdb 100644 --- a/les/backend.go +++ b/les/backend.go @@ -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 { diff --git a/light/lightchain.go b/light/lightchain.go index 26b5df09172b..9cbf95ddf9c6 100644 --- a/light/lightchain.go +++ b/light/lightchain.go @@ -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() { diff --git a/node/node.go b/node/node.go index 40cef4bab342..b8deaa1e857c 100644 --- a/node/node.go +++ b/node/node.go @@ -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() diff --git a/node/node_example_test.go b/node/node_example_test.go index b2ad1a8ed3e0..c16aad73ab27 100644 --- a/node/node_example_test.go +++ b/node/node_example_test.go @@ -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() { diff --git a/node/service.go b/node/service.go index 5d0358b93123..8bfc71884f50 100644 --- a/node/service.go +++ b/node/service.go @@ -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 diff --git a/node/utils_test.go b/node/utils_test.go index d6aff608e05d..4f6034f47eca 100644 --- a/node/utils_test.go +++ b/node/utils_test.go @@ -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 } @@ -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() diff --git a/p2p/simulations/adapters/exec.go b/p2p/simulations/adapters/exec.go index 1ab534f8d07f..153aa32d6491 100644 --- a/p2p/simulations/adapters/exec.go +++ b/p2p/simulations/adapters/exec.go @@ -504,8 +504,6 @@ func (s *snapshotService) Start(*p2p.Server) error { return nil } -func (s *snapshotService) SaveData() { -} func (s *snapshotService) Stop() error { return nil } diff --git a/p2p/simulations/examples/ping-pong.go b/p2p/simulations/examples/ping-pong.go index 450ab047906e..144035348b69 100644 --- a/p2p/simulations/examples/ping-pong.go +++ b/p2p/simulations/examples/ping-pong.go @@ -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 diff --git a/p2p/simulations/http_test.go b/p2p/simulations/http_test.go index 2bc2e0fecc78..7121cc4c0d8c 100644 --- a/p2p/simulations/http_test.go +++ b/p2p/simulations/http_test.go @@ -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 } diff --git a/p2p/testing/protocoltester.go b/p2p/testing/protocoltester.go index 622d63bfe324..df291202a0ff 100644 --- a/p2p/testing/protocoltester.go +++ b/p2p/testing/protocoltester.go @@ -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 } @@ -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