Skip to content

Commit

Permalink
Fix rance in GetBestMiningCandidate
Browse files Browse the repository at this point in the history
Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
  • Loading branch information
Jakub Sztandera committed Jun 23, 2020
1 parent 156a14e commit 29bfd8a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
5 changes: 2 additions & 3 deletions api/test/mining.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,11 +133,10 @@ func TestDealMining(t *testing.T, b APIBuilder, blocktime time.Duration, carExpo
wait := make(chan int, 2)
mdone := func(mined bool) {
go func() {
n := 0
if mined {
n = 1
wait <- 1
}
wait <- n
wait <- 0
}()
}

Expand Down
3 changes: 3 additions & 0 deletions miner/miner.go
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,9 @@ type MiningBase struct {
}

func (m *Miner) GetBestMiningCandidate(ctx context.Context) (*MiningBase, error) {
m.lk.Lock()
defer m.lk.Unlock()

bts, err := m.api.ChainHead(ctx)
if err != nil {
return nil, err
Expand Down

0 comments on commit 29bfd8a

Please sign in to comment.