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
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
619cff7
multi: update blockchain error types.
dnldd Jul 20, 2020
7130600
rpcserver: Add handleEstimateStakeDiff test.
JoeGruffins Jul 13, 2020
276f0ef
rpcserver: Add handleGetTicketPoolValue test.
rstaudt2 Jul 17, 2020
4cfd644
rpcserver: Add handleGetStakeVersions test.
rstaudt2 Jul 17, 2020
7222f22
rpcserver: Add handleGetStakeVersionInfo test.
rstaudt2 Jul 17, 2020
700bba8
multi: Decouple blockManager from mining.
sefbkn Feb 13, 2020
8932319
multi: Hide CPUMiner WaitGroup.
sefbkn Feb 13, 2020
7f21cf1
multi: Move mining code into mining package.
sefbkn Jul 18, 2020
41a1454
mempool: Don't use deprecated reject code in tests.
davecgh Jul 19, 2020
35e6176
mempool: Remove deprecated ErrToRejectErr func.
davecgh Jul 19, 2020
6b0c890
mempool: Remove deprecated tx rule err reject code.
davecgh Jul 19, 2020
5c5b41b
mempool: Remove deprecated DisableLog func.
davecgh Jul 19, 2020
23d86d6
mempool: Move to internal.
davecgh Jul 19, 2020
f6ca67c
docs: Update for removal of mempool module.
davecgh Jul 19, 2020
b23f043
mining: Move to internal.
davecgh Jul 19, 2020
5581551
docs: Update for removal of mining module.
davecgh Jul 19, 2020
c4e5c21
wire: formatting fixes - no functional change
dajohi Jul 15, 2020
41bec0b
wire: return detectable err from makeEmptyMessage.
dajohi Jul 16, 2020
080cdea
build: golangci-lint v1.28.3
dajohi Jul 16, 2020
d3437f6
rpcserver: add missed and live tickets rpc tests.
dnldd Jul 21, 2020
826f2a5
mining: Improve comment for UpdateBlockTime.
davecgh Jul 19, 2020
4214726
cpuminer: Refactor code to its own package.
davecgh Jul 19, 2020
c301c0e
multi: update mempool error types.
dnldd Jul 24, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
- name: Check out source
uses: actions/checkout@v2
- name: Install Linters
run: "curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s -- -b $(go env GOPATH)/bin v1.27.0"
run: "curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s -- -b $(go env GOPATH)/bin v1.28.3"
- name: Build
env:
GO111MODULE: "on"
Expand Down
11 changes: 6 additions & 5 deletions blockchain/chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -1213,21 +1213,22 @@ func (b *BlockChain) forceHeadReorganization(formerBest chainhash.Hash, newBest
// We can't reorganize the chain unless our head block matches up with
// b.bestChain.
if !formerBestNode.hash.IsEqual(&formerBest) {
return ruleError(ErrForceReorgWrongChain, "tried to force reorg "+
"on wrong chain")
str := "tried to force reorg on wrong chain"
return ruleError(ErrForceReorgWrongChain, str)
}

// Child to reorganize to is missing.
newBestNode := b.index.LookupNode(&newBest)
if newBestNode == nil || newBestNode.parent != formerBestNode.parent {
return ruleError(ErrForceReorgMissingChild, "missing child of "+
"common parent for forced reorg")
str := "missing child of common parent for forced reorg"
return ruleError(ErrForceReorgMissingChild, str)
}

// Don't allow a reorganize to a known invalid chain.
newBestNodeStatus := b.index.NodeStatus(newBestNode)
if newBestNodeStatus.KnownInvalid() {
return ruleError(ErrKnownInvalidBlock, "block is known to be invalid")
str := "block is known to be invalid"
return ruleError(ErrKnownInvalidBlock, str)
}

// Reorganize the chain and flush any potential unsaved changes to the
Expand Down
9 changes: 4 additions & 5 deletions blockchain/chain_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,8 @@ func TestForceHeadReorg(t *testing.T) {
//
// rejectForceTipReorg forces the chain instance to reorganize the
// current tip of the main chain from the given block to the given
// block and expected it to be rejected with the provided error code.
rejectForceTipReorg := func(fromTipName, toTipName string, code ErrorCode) {
// block and expected it to be rejected with the provided error kind.
rejectForceTipReorg := func(fromTipName, toTipName string, errKind ErrorKind) {
from := g.BlockByName(fromTipName)
to := g.BlockByName(toTipName)
t.Logf("Testing forced reorg from %s (hash %s, height %d) "+
Expand Down Expand Up @@ -179,14 +179,13 @@ func TestForceHeadReorg(t *testing.T) {
from.BlockHash(), from.Header.Height, toTipName,
to.BlockHash(), to.Header.Height, err)
}
if rerr.ErrorCode != code {
if !errors.Is(rerr, errKind) {
t.Fatalf("forced header reorg from block %q (hash %s, "+
"height %d) to block %q (hash %s, height %d) "+
"does not have expected reject code -- got %v, "+
"want %v", fromTipName,
from.BlockHash(), from.Header.Height, toTipName,
to.BlockHash(), to.Header.Height, rerr.ErrorCode,
code)
to.BlockHash(), to.Header.Height, rerr, errKind)
}
}

Expand Down
12 changes: 6 additions & 6 deletions blockchain/common_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -369,8 +369,8 @@ func (g *chaingenHarness) AcceptTipBlock() {
}

// RejectBlock expects the block associated with the given name in the harness
// generator to be rejected with the provided error code.
func (g *chaingenHarness) RejectBlock(blockName string, code ErrorCode) {
// generator to be rejected with the provided error kind.
func (g *chaingenHarness) RejectBlock(blockName string, errKind ErrorKind) {
g.t.Helper()

msgBlock := g.BlockByName(blockName)
Expand All @@ -393,19 +393,19 @@ func (g *chaingenHarness) RejectBlock(blockName string, code ErrorCode) {
"type -- got %T, want blockchain.RuleError", blockName,
block.Hash(), blockHeight, err)
}
if rerr.ErrorCode != code {
if !errors.Is(rerr, errKind) {
g.t.Fatalf("block %q (hash %s, height %d) does not have expected reject "+
"code -- got %v, want %v", blockName, block.Hash(), blockHeight,
rerr.ErrorCode, code)
rerr, errKind)
}
}

// RejectTipBlock expects the current tip block associated with the harness
// generator to be rejected with the provided error code.
func (g *chaingenHarness) RejectTipBlock(code ErrorCode) {
func (g *chaingenHarness) RejectTipBlock(errKind ErrorKind) {
g.t.Helper()

g.RejectBlock(g.TipName(), code)
g.RejectBlock(g.TipName(), errKind)
}

// ExpectTip expects the provided block to be the current tip of the main chain
Expand Down
Loading