mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-19 02:12:23 +00:00
fix peer open/closing issue
use custom fns for this dont touch the quit channel
This commit is contained in:
parent
1a84964762
commit
562164afe0
2 changed files with 13 additions and 3 deletions
|
|
@ -365,7 +365,7 @@ func New(stack *node.Node, config *ethconfig.Config) (*Ethereum, error) {
|
|||
// ensure 5 seconds has passed between blocks before we start peering so we are sure sync has finished
|
||||
if time.Now().Unix()-eth.timeLastBlock >= 5 {
|
||||
log.Info("Networking and peering start...")
|
||||
eth.handler.peers.open()
|
||||
eth.handler.peers.SetOpen()
|
||||
eth.p2pServer.Start()
|
||||
eth.Downloader().DoneEvent()
|
||||
eth.handler.synced.Store(true)
|
||||
|
|
@ -522,7 +522,7 @@ func (s *Ethereum) Start() error {
|
|||
// SYSCOIN
|
||||
if s.blockchain.GetChainConfig().SyscoinBlock != nil {
|
||||
log.Info("Skip networking and peering...")
|
||||
s.handler.peers.close()
|
||||
s.handler.peers.SetClosed()
|
||||
s.p2pServer.Stop()
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -239,9 +239,19 @@ func (ps *peerSet) close() {
|
|||
}
|
||||
|
||||
// SYSCOIN
|
||||
func (ps *peerSet) open() {
|
||||
func (ps *peerSet) SetOpen() {
|
||||
ps.lock.Lock()
|
||||
defer ps.lock.Unlock()
|
||||
|
||||
ps.closed = false
|
||||
}
|
||||
func (ps *peerSet) SetClosed() {
|
||||
ps.lock.Lock()
|
||||
defer ps.lock.Unlock()
|
||||
|
||||
for _, p := range ps.peers {
|
||||
p.Disconnect(p2p.DiscQuitting)
|
||||
}
|
||||
|
||||
ps.closed = true
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue