Merge pull request #774 from gzliudan/rm_SaveData

all: remove empty function SaveData()
This commit is contained in:
Daniel Liu 2024-12-28 09:05:43 +08:00 committed by GitHub
commit 43ad328487
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
15 changed files with 4 additions and 47 deletions

View file

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

View file

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

View file

@ -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")
}

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -504,8 +504,6 @@ func (s *snapshotService) Start(*p2p.Server) error {
return nil
}
func (s *snapshotService) SaveData() {
}
func (s *snapshotService) Stop() error {
return nil
}

View file

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

View file

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

View file

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