Skip to content

Commit

Permalink
swarm/storage: fix mockNetFetcher data races (ethereum#18462)
Browse files Browse the repository at this point in the history
  • Loading branch information
janos authored and zelig committed Jan 16, 2019
1 parent 96c7c18 commit f728837
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions swarm/storage/netstore_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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 {
Expand Down

0 comments on commit f728837

Please sign in to comment.