Disable consensus and close p2p service. (#8)

* stop p2p and sync handler

* disable clique consensus create block

* Close useless code about p2p settings.
This commit is contained in:
maskpp 2021-12-17 13:56:40 +08:00 committed by GitHub
parent ee15a2652f
commit a4eb31f4d2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 22 additions and 22 deletions

View file

@ -327,9 +327,9 @@ func (c *Clique) verifyCascadingFields(chain consensus.ChainHeaderReader, header
if parent == nil || parent.Number.Uint64() != number-1 || parent.Hash() != header.ParentHash {
return consensus.ErrUnknownAncestor
}
if parent.Time+c.config.Period > header.Time {
/*if parent.Time+c.config.Period > header.Time {
return errInvalidTimestamp
}
}*/
// Verify that the gasUsed is <= gasLimit
if header.GasUsed > header.GasLimit {
return fmt.Errorf("invalid gasUsed: have %d, gasLimit %d", header.GasUsed, header.GasLimit)
@ -553,10 +553,10 @@ func (c *Clique) Prepare(chain consensus.ChainHeaderReader, header *types.Header
if parent == nil {
return consensus.ErrUnknownAncestor
}
header.Time = parent.Time + c.config.Period
if header.Time < uint64(time.Now().Unix()) {
header.Time = uint64(time.Now().Unix())
}
//header.Time = parent.Time + c.config.Period
//if header.Time < uint64(time.Now().Unix()) {
header.Time = uint64(time.Now().Unix())
//}
return nil
}

View file

@ -524,21 +524,21 @@ func (s *Ethereum) Protocols() []p2p.Protocol {
// Start implements node.Lifecycle, starting all internal goroutines needed by the
// Ethereum protocol implementation.
func (s *Ethereum) Start() error {
eth.StartENRUpdater(s.blockchain, s.p2pServer.LocalNode())
//eth.StartENRUpdater(s.blockchain, s.p2pServer.LocalNode())
// Start the bloom bits servicing goroutines
s.startBloomHandlers(params.BloomBitsBlocks)
// Figure out a max peers count based on the server limits
maxPeers := s.p2pServer.MaxPeers
if s.config.LightServ > 0 {
if s.config.LightPeers >= s.p2pServer.MaxPeers {
return fmt.Errorf("invalid peer config: light peer count (%d) >= total peer count (%d)", s.config.LightPeers, s.p2pServer.MaxPeers)
}
maxPeers -= s.config.LightPeers
}
//maxPeers := s.p2pServer.MaxPeers
//if s.config.LightServ > 0 {
// if s.config.LightPeers >= s.p2pServer.MaxPeers {
// return fmt.Errorf("invalid peer config: light peer count (%d) >= total peer count (%d)", s.config.LightPeers, s.p2pServer.MaxPeers)
// }
// maxPeers -= s.config.LightPeers
//}
// Start the networking layer and the light server if requested
s.handler.Start(maxPeers)
//s.handler.Start(maxPeers)
return nil
}
@ -548,7 +548,7 @@ func (s *Ethereum) Stop() error {
// Stop all the peer-related stuff first.
s.ethDialCandidates.Close()
s.snapDialCandidates.Close()
s.handler.Stop()
//s.handler.Stop()
// Then stop everything else.
s.bloomIndexer.Close()

View file

@ -393,10 +393,10 @@ func (w *worker) newWorkLoop(recommit time.Duration) {
timestamp = time.Now().Unix()
commit(false, commitInterruptNewHead)
case head := <-w.chainHeadCh:
/*case head := <-w.chainHeadCh:
clearPending(head.Block.NumberU64())
timestamp = time.Now().Unix()
commit(false, commitInterruptNewHead)
commit(false, commitInterruptNewHead)*/
case <-timer.C:
// If mining is running resubmit a new work cycle periodically to pull in

View file

@ -261,15 +261,15 @@ func (n *Node) doClose(errs []error) error {
// openEndpoints starts all network and RPC endpoints.
func (n *Node) openEndpoints() error {
// start networking endpoints
n.log.Info("Starting peer-to-peer node", "instance", n.server.Name)
/*n.log.Info("Starting peer-to-peer node", "instance", n.server.Name)
if err := n.server.Start(); err != nil {
return convertFileLockError(err)
}
}*/
// start RPC endpoints
err := n.startRPC()
if err != nil {
n.stopRPC()
n.server.Stop()
//n.server.Stop()
}
return err
}
@ -298,7 +298,7 @@ func (n *Node) stopServices(running []Lifecycle) error {
}
// Stop p2p networking.
n.server.Stop()
//n.server.Stop()
if len(failure.Services) > 0 {
return failure