未验证 提交 dd3e8947 编写于 作者: J Janoš Guljaš 提交者: Rafael Matias

swarm/storage: fix mockNetFetcher data races (#18462)

fixes: ethersphere/go-ethereum#1117
(cherry picked from commit f728837e)
上级 df355ece
......@@ -43,6 +43,7 @@ type mockNetFetcher struct {
quit <-chan struct{}
ctx context.Context
hopCounts []uint8
mu sync.Mutex
}
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) {
m.mu.Lock()
defer m.mu.Unlock()
m.requestCalled = true
var peers []Address
m.peers.Range(func(key interface{}, _ interface{}) bool {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册