fix peer open/closing issue

use custom fns for this dont touch the quit channel
This commit is contained in:
jagdeep sidhu 2024-10-11 13:43:28 -07:00
parent 1a84964762
commit 562164afe0
2 changed files with 13 additions and 3 deletions

View file

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

View file

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