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

multi: update mempool error types. #2296

Closed
wants to merge 23 commits into from

Conversation

dnldd
Copy link
Member

@dnldd dnldd commented Jul 24, 2020

Depends on #2278

This updates the standalone error types to leverage go 1.13 errors.Is/As functionality as well as conform to the error infrastructure best practices outlined in #2181.

dnldd and others added 23 commits July 20, 2020 12:18
This updates the blockchain error types to leverage go
1.13 errors.Is/As functionality as well as confirm to
the error infrastructure best practices.
Because handleEstimateStakeDiff calls chain.EstimateNextStakeDifficulty
up to four times, change testRPCChain.estimateNextStakeDifficulty to a
function so that handlers can specify more complex return values. In
TestHandleExtimateStakeDiff, have the test RPC chain return functions
that return results from a queue, allowing for multiple calls with
varying results.

Use go-spew to print test result equality errors so that values of
pointers are also printed.
This removes coupling between the mining code,
blockManager, and the main configuration.

This change is a step towards moving
the mining code into its own package.
This change wraps the CPUMiner's
WaitGroup reference in preparation for
moving the CPUMiner under the mining
package.
This contains the changes necessary to move the
mining code into the mining package.  The motivation
behind these changes is to decouple the block template
generation from other modules in the codebase to
simplify extending it with new features and tests.
This updates the tests to use error codes instead of the deprecated
reject codes.
This removes the deprecated ErrToRejectErr function and also removes
extractRejectCode since it has no other callers.
This removes the deprecated RejectCode from the TxRuleError struct and
updates all of the callers accordingly.
This removes the deprecated DisableLog function since the major version
has been bumped since the last release.
This makes the mempool an internal package such that it will no longer
be an exported module.  The only place its functionality is really
needed is for the internal implementation of dcrd itself and thus having
an unnecessary exported module significantly increases the maintenance
burden.

This is part of the overall effort to reduce the total number of modules
and eventually get to the point it will be possible to follow semver for
the root module.

It is worth noting that there are a few constants, which will be listed
below, that were exported from this module that callers might have
previously relied upon.  However, due to previous discussions about the
goal of removing the module, a code search has revealed that there are
no known callers that still rely on them.

The aforementioned constants are:

- MaxStandardTxSize
- DefaultMinRelayTxFee
- BaseStandardVerifyFlags

Overview of the major changes:

- Move the following files from mempool -> internal/mempool:
  - README.md
  - doc.go
  - error.go
  - log.go
  - mempool.go
  - mempool_test.go
  - policy.go
  - policy_test.go
- Remove mempool/go.mod and mempool/go.sum
- Make the README.md and doc.go files match the new reality
- Update all import paths in the repository accordingly
- Remove the dependency from the root go.mod
- Run go mod tidy on all modules
This makes the mining package an internal package such that it will no
longer be an exported module.  The only place its functionality is
really needed is for the internal implementation of dcrd itself and thus
having an unnecessary exported module significantly increases the
maintenance burden.

This is part of the overall effort to reduce the total number of modules
and eventually get to the point it will be possible to follow semver for
the root module.

It is worth noting that there are a few constants, which will be listed
below, that were exported from this module that callers might have
previously relied upon.  However, due to previous discussions about the
goal of removing the module, a code search has revealed that there are
no known callers that still rely on them.

The aforementioned constants are:

- UnminedHeight
- MinHighPriority

Overview of the major changes:

- Move the following files from mining -> internal/mining:
  - README.md
  - cpuminer.go
  - doc.go
  - miningerror.go -> error.go
  - log.go
  - mining.go
  - mining_test.go
  - policy.go
  - policy_test.go
- Remove mining/go.mod and mining/go.sum
- Make the README.md and doc.go files match the new reality
- Update all import paths in the repository accordingly
- Remove the dependency from the root go.mod
- Run go mod tidy on all modules
This adds tests for the missed and live ticket rpcs
as well as the validate address rpc.
This does the minimum work necessary to refactor the CPU miner code into
its own internal package.  The idea is that separating this code into
its own package will improve its testability and ultimately be useful to
other parts of the codebase such as the various tests which currently
effectively have their own stripped-down versions of this code.

The API will certainly need some additional cleanup and changes to make
it more usable outside of the specific circumstances it was originally
designed to support (namely the generate RPC), however it is better to
do that in future commits in order to keep the changeset as small as
possible during this refactor.

Overview of the major changes:

- Create the new package
- Move internal/mining/cpuminer.go -> internal/mining/cpuminer/cpuminer.go
- Update mining logging to use the new cpuminer package logger
- Rename CPUMinerConfig to Config (so it's now cpuminer.Config)
- Rename NewCPUMiner to New (so it's now cpuminer.New)
- Add exported BestSnapshot method to mining.BlkTmplGenerator
- Add exported TxSource method to mining.BlkTmplGenerator
- Update all references to the cpuminer to use the package
- Add a skeleton README.md
- Add a skeleton doc.go
This updates the standalone error types to leverage go 1.13
errors.Is/As functionality as well as conform to the error
infrastructure best practices.
@davecgh davecgh added this to the 1.7.0 milestone Jul 24, 2020
@dnldd
Copy link
Member Author

dnldd commented Oct 14, 2020

The changes made here have been pulled into #2278, closing.

@dnldd dnldd closed this Oct 14, 2020
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.

6 participants