mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-05-16 04:56:36 +00:00
swarm/storage: fix mockNetFetcher data races (#18462)
fixes: ethersphere/go-ethereum#1117
(cherry picked from commit f728837ee6)
This commit is contained in:
parent
df355eceb4
commit
dd3e894747
1 changed files with 4 additions and 0 deletions
|
|
@ -43,6 +43,7 @@ type mockNetFetcher struct {
|
||||||
quit <-chan struct{}
|
quit <-chan struct{}
|
||||||
ctx context.Context
|
ctx context.Context
|
||||||
hopCounts []uint8
|
hopCounts []uint8
|
||||||
|
mu sync.Mutex
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *mockNetFetcher) Offer(ctx context.Context, source *enode.ID) {
|
func (m *mockNetFetcher) Offer(ctx context.Context, source *enode.ID) {
|
||||||
|
|
@ -51,6 +52,9 @@ func (m *mockNetFetcher) Offer(ctx context.Context, source *enode.ID) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *mockNetFetcher) Request(ctx context.Context, hopCount uint8) {
|
func (m *mockNetFetcher) Request(ctx context.Context, hopCount uint8) {
|
||||||
|
m.mu.Lock()
|
||||||
|
defer m.mu.Unlock()
|
||||||
|
|
||||||
m.requestCalled = true
|
m.requestCalled = true
|
||||||
var peers []Address
|
var peers []Address
|
||||||
m.peers.Range(func(key interface{}, _ interface{}) bool {
|
m.peers.Range(func(key interface{}, _ interface{}) bool {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue