les: fix data races in tests (#23457)

This commit is contained in:
gary rong
2021-08-25 17:56:25 +08:00
committed by GitHub
parent fe2f153b55
commit 83ad92c421
8 changed files with 48 additions and 76 deletions

View File

@ -153,9 +153,7 @@ type lightFetcher struct {
synchronise func(peer *serverPeer)
// Test fields or hooks
noAnnounce bool
newHeadHook func(*types.Header)
newAnnounce func(*serverPeer, *announceData)
}
// newLightFetcher creates a light fetcher instance.
@ -474,12 +472,6 @@ func (f *lightFetcher) mainloop() {
// announce processes a new announcement message received from a peer.
func (f *lightFetcher) announce(p *serverPeer, head *announceData) {
if f.newAnnounce != nil {
f.newAnnounce(p, head)
}
if f.noAnnounce {
return
}
select {
case f.announceCh <- &announce{peerid: p.ID(), trust: p.trusted, data: head}:
case <-f.closeCh: