dcrd/internal/mining
Matheus Degiovani 4bcad7be57 mining: Switch to custom waitGroup impl
This fixes race errors caused by incorrect usage of sync.WaitGroup.

sync.WaitGroup has a restriction when first used on an empty value:
calls to Add() and Wait() must be synchronized, such that the initial
Wait() is not called concurrently to any other Add().

However, the background template generator breaks this premise by
allowing invocations of both Wait() and Add() from different goroutines.
For example, Wait() can be called from an rpcserver handler method while
an Add() is called from an internal goroutine. This causes a potential
race condition.

This can be verified by installing dcrd with `-race`, then running the
TestTreasury test of the internal/rpcserver package.

We fix this issue by switching to a local implementation of the wait
group that retains the same semantics as the one from the stdlib but
lifts the aforementioned restriction.

This is accomplished by using a global lock on the wait group instead of
the semaphore-based implementation currently used in the stdlib.
2020-11-25 13:14:37 -06:00
..
cpuminer multi: Start blockchain v4 module dev cycle. 2020-11-10 16:51:38 -06:00
bgblktmplgenerator_test.go mining: Switch to custom waitGroup impl 2020-11-25 13:14:37 -06:00
bgblktmplgenerator.go mining: Switch to custom waitGroup impl 2020-11-25 13:14:37 -06:00
doc.go cpuminer: Refactor code to its own package. 2020-07-22 20:06:28 -05:00
error.go mining: Add ticket exhaustion check. 2020-10-05 19:29:28 -05:00
interface.go mining: Move txMiningView from mempool package. 2020-11-17 20:12:00 -06:00
log.go mining: Move to internal. 2020-07-20 18:07:59 -05:00
mining_view.go mining: Move txMiningView from mempool package. 2020-11-17 20:12:00 -06:00
mining.go mempool: Limit ancestor tracking in mempool. 2020-11-17 18:41:47 -06:00
policy_test.go mining: Move to internal. 2020-07-20 18:07:59 -05:00
policy.go mining: Move interfaces to mining/interface.go. 2020-10-16 15:13:57 -05:00
README.md mining: Move to internal. 2020-07-20 18:07:59 -05:00
tx_desc_graph.go mining: Move txMiningView from mempool package. 2020-11-17 20:12:00 -06:00
txpriorityqueue_test.go mining: Cleanup txPriorityQueue tests. 2020-10-16 15:13:57 -05:00
txpriorityqueue.go mining: Move txPriorityQueue to a separate file. 2020-10-16 15:13:57 -05:00

mining

Build Status ISC License Doc

Overview

This package is currently a work in progress.

License

Package mining is licensed under the copyfree ISC License.