Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mempool/mining: Introduce TxSource interface. #225

Merged
merged 2 commits into from May 26, 2016

Conversation

davecgh
Copy link
Member

@davecgh davecgh commented May 25, 2016

Upstream commit 2b6a9a5.

NOTE: This is only merging in the upstream changes, so while they are useful for Decred as well, this merge commit does fully separate the mempool as upstream does due to the new functionality provided by Decred.

This introduces the concept of a new interface named TxSource which aims
to generically provide a concurrent safe source of transactions to be
considered for inclusion in a new block.  This is a step towards
decoupling the mining code from the internals of btcd.  Ultimately the
intent is to create a separate mining package.

The new TxSource interface relies on a new struct named miningTxDesc,
which describes each entry in the transaction source.  Once this code is
refactored into a separate mining package, the mining prefix can simply
be dropped leaving the type exported as mining.TxDesc.

To go along with this, the existing TxDesc type in the mempool has been
renamed to mempoolTxDesc and changed to embed the new miningTxDesc type.
This allows the mempool to efficiently implement the MiningTxDescs
method needed to satisfy the TxSource interface.

This approach effectively separates the direct reliance of the mining
code on the mempool and its data structures.  Even though the memory
pool will still be the default concrete implementation of the interface,
making it an interface offers much more flexibility in terms of testing
and even provides the potential to allow more than one source (perhaps
multiple independent relay networks, for example).

Finally, the memory pool and all of the mining code has been updated to
implement and use the new interface.
@alexlyp
Copy link
Member

alexlyp commented May 25, 2016

tACK so far on testnet

review looks good

Upstream commit 2b6a9a5.

NOTE: This is only merging in the upstream changes, so while they are
useful for Decred as well, this merge commit does fully separate the
mempool as upstream does due to the new functionality provided by
Decred.
@jolan
Copy link
Contributor

jolan commented May 26, 2016

tACK. Have mined 10 blocks on testnet so far with this.

@cjepson
Copy link
Contributor

cjepson commented May 26, 2016

utACK

@alexlyp alexlyp merged commit 9031d85 into decred:master May 26, 2016
@davecgh davecgh deleted the merge_introduce_txsource branch May 26, 2016 21:25
@jcvernaleo jcvernaleo added this to the v0.1.5 milestone May 27, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants