mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 10:52:25 +00:00
eth: fix crash in ethclient tests
This commit is contained in:
parent
84fac80fe4
commit
a9b863ea51
2 changed files with 14 additions and 12 deletions
|
|
@ -522,7 +522,7 @@ func (s *Ethereum) Protocols() []p2p.Protocol {
|
||||||
// Start implements node.Service, starting all internal goroutines needed by the
|
// Start implements node.Service, starting all internal goroutines needed by the
|
||||||
// Ethereum protocol implementation.
|
// Ethereum protocol implementation.
|
||||||
func (s *Ethereum) Start(srvr *p2p.Server) error {
|
func (s *Ethereum) Start(srvr *p2p.Server) error {
|
||||||
go s.enrUpdateLoop(srvr.LocalNode())
|
s.startEthEntryUpdate(srvr.LocalNode())
|
||||||
|
|
||||||
// Start the bloom bits servicing goroutines
|
// Start the bloom bits servicing goroutines
|
||||||
s.startBloomHandlers(params.BloomBitsBlocks)
|
s.startBloomHandlers(params.BloomBitsBlocks)
|
||||||
|
|
|
||||||
|
|
@ -37,11 +37,12 @@ func (e ethEntry) ENRKey() string {
|
||||||
return "eth"
|
return "eth"
|
||||||
}
|
}
|
||||||
|
|
||||||
func (eth *Ethereum) enrUpdateLoop(ln *enode.LocalNode) {
|
func (eth *Ethereum) startEthEntryUpdate(ln *enode.LocalNode) {
|
||||||
var newHead = make(chan core.ChainHeadEvent, 10)
|
var newHead = make(chan core.ChainHeadEvent, 10)
|
||||||
sub := eth.blockchain.SubscribeChainHeadEvent(newHead)
|
sub := eth.blockchain.SubscribeChainHeadEvent(newHead)
|
||||||
defer sub.Unsubscribe()
|
|
||||||
|
|
||||||
|
go func() {
|
||||||
|
defer sub.Unsubscribe()
|
||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
case <-newHead:
|
case <-newHead:
|
||||||
|
|
@ -52,6 +53,7 @@ func (eth *Ethereum) enrUpdateLoop(ln *enode.LocalNode) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (eth *Ethereum) currentEthEntry() *ethEntry {
|
func (eth *Ethereum) currentEthEntry() *ethEntry {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue