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

chaingen: Prevent dup block names in NextBlock. #1079

Merged
merged 1 commit into from
Feb 25, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
5 changes: 5 additions & 0 deletions blockchain/chaingen/generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -1701,6 +1701,11 @@ func updateVoteCommitments(block *wire.MsgBlock) {
// - The size of the block will be recalculated unless it was manually changed
// - The block will be solved unless the nonce was changed
func (g *Generator) NextBlock(blockName string, spend *SpendableOut, ticketSpends []SpendableOut, mungers ...func(*wire.MsgBlock)) *wire.MsgBlock {
// Prevent block name collisions.
if g.blocksByName[blockName] != nil {
panic(fmt.Sprintf("block name %s already exists", blockName))
}

// Calculate the next required stake difficulty (aka ticket price).
ticketPrice := dcrutil.Amount(g.calcNextRequiredStakeDifficulty())

Expand Down
9 changes: 4 additions & 5 deletions blockchain/fullblocktests/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -382,11 +382,11 @@ func Generate(includeLargeReorg bool) (tests [][]TestInstance, err error) {
//
// rejectNonCanonicalBlock creates a test instance that encodes the
// provided block using a non-canonical encoded as described by the
// encodeNonCanonicalBlock function and expected it to be rejected.
// encodeNonCanonicalBlock function and expects it to be rejected.
//
// orphanOrRejectBlock creates a test instance that expected the
// provided block to either by accepted as an orphan or rejected by the
// consensus rules.
// orphanOrRejectBlock creates a test instance that expects the provided
// block to either be accepted as an orphan or rejected by the consensus
// rules.
//
// expectTipBlock creates a test instance that expects the provided
// block to be the current tip of the block chain.
Expand Down Expand Up @@ -1464,7 +1464,6 @@ func Generate(includeLargeReorg bool) (tests [][]TestInstance, err error) {
coinbaseOuts := g.OldestCoinbaseOuts()
outs = append(outs, &coinbaseOuts[0])
ticketOuts = append(ticketOuts, coinbaseOuts[1:])

}

// ---------------------------------------------------------------------
Expand Down