Skip to content

Commit

Permalink
Disable consensus and close p2p service. (#8)
Browse files Browse the repository at this point in the history
* stop p2p and sync handler

* disable clique consensus create block

* Close useless code about p2p settings.
  • Loading branch information
mask-pp authored Dec 17, 2021
1 parent ee15a26 commit a4eb31f
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 22 deletions.
12 changes: 6 additions & 6 deletions consensus/clique/clique.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
}

Expand Down
20 changes: 10 additions & 10 deletions eth/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand All @@ -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()
Expand Down
4 changes: 2 additions & 2 deletions miner/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions node/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit a4eb31f

Please sign in to comment.