From 1172773907d28e231255ce45282fbf168b53720a Mon Sep 17 00:00:00 2001 From: Dave Collins Date: Mon, 26 Feb 2018 17:54:04 -0600 Subject: [PATCH] chaingen: Accept mungers for create premine block. This modifies the CreatePremineBlock in chaingen to accept mungers similar to NextBlock. --- blockchain/chaingen/generator.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/blockchain/chaingen/generator.go b/blockchain/chaingen/generator.go index 39ff8bc512..67802699d0 100644 --- a/blockchain/chaingen/generator.go +++ b/blockchain/chaingen/generator.go @@ -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{}, @@ -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