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: Accept mungers for create premine block. #1090

Merged
merged 1 commit into from
Feb 27, 2018
Merged
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
8 changes: 5 additions & 3 deletions blockchain/chaingen/generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -2092,7 +2092,7 @@ func (g *Generator) NextBlock(blockName string, spend *SpendableOut, ticketSpend
// premine payouts. The additional amount parameter can be used to create a
// block that is otherwise a completely valid premine block except it adds the
// extra amount to each payout and thus create a block that violates consensus.
func (g *Generator) CreatePremineBlock(blockName string, additionalAmount dcrutil.Amount) *wire.MsgBlock {
func (g *Generator) CreatePremineBlock(blockName string, additionalAmount dcrutil.Amount, mungers ...func(*wire.MsgBlock)) *wire.MsgBlock {
coinbaseTx := wire.NewMsgTx()
coinbaseTx.AddTxIn(&wire.TxIn{
PreviousOutPoint: *wire.NewOutPoint(&chainhash.Hash{},
Expand Down Expand Up @@ -2127,9 +2127,11 @@ func (g *Generator) CreatePremineBlock(blockName string, additionalAmount dcruti
coinbaseTx.TxIn[0].ValueIn = int64(totalSubsidy)

// Generate the block with the specially created regular transactions.
return g.NextBlock(blockName, nil, nil, func(b *wire.MsgBlock) {
munger := func(b *wire.MsgBlock) {
b.Transactions = []*wire.MsgTx{coinbaseTx}
})
}
mungers = append([]func(*wire.MsgBlock){munger}, mungers...)
return g.NextBlock(blockName, nil, nil, mungers...)
}

// UpdateBlockState manually updates the generator state to remove all internal
Expand Down