From 05d46e7c01f17227c4cdb1c4976ce2933eeeb7ed Mon Sep 17 00:00:00 2001 From: Ori Newman Date: Tue, 6 Nov 2018 11:26:59 +0200 Subject: [PATCH] [DEV-244] Remove BlockHeader.NumParentBlocks and use a method instead (#121) --- blockdag/blockindex.go | 13 +++-- blockdag/fullblocktests/generate.go | 13 +++-- blockdag/fullblocktests/params.go | 13 +++-- blockdag/validate.go | 2 +- blockdag/validate_test.go | 6 +-- dagconfig/genesis.go | 52 +++++++++---------- database/testdata/generator.go | 13 +++-- mining/mining.go | 11 ++-- util/block_test.go | 3 +- wire/blockheader.go | 38 +++++++------- wire/blockheader_test.go | 78 +++++++++++++---------------- wire/msgblock_test.go | 7 ++- wire/msgmerkleblock_test.go | 5 +- 13 files changed, 118 insertions(+), 136 deletions(-) diff --git a/blockdag/blockindex.go b/blockdag/blockindex.go index cdd677e98..e84e2f54f 100644 --- a/blockdag/blockindex.go +++ b/blockdag/blockindex.go @@ -163,13 +163,12 @@ func newBlockNode(blockHeader *wire.BlockHeader, parents blockSet, phantomK uint func (node *blockNode) Header() *wire.BlockHeader { // No lock is needed because all accessed fields are immutable. return &wire.BlockHeader{ - Version: node.version, - NumParentBlocks: byte(len(node.parents)), - ParentHashes: node.ParentHashes(), - MerkleRoot: node.merkleRoot, - Timestamp: time.Unix(node.timestamp, 0), - Bits: node.bits, - Nonce: node.nonce, + Version: node.version, + ParentHashes: node.ParentHashes(), + MerkleRoot: node.merkleRoot, + Timestamp: time.Unix(node.timestamp, 0), + Bits: node.bits, + Nonce: node.nonce, } } diff --git a/blockdag/fullblocktests/generate.go b/blockdag/fullblocktests/generate.go index 58a43885f..2f3a1ffbb 100644 --- a/blockdag/fullblocktests/generate.go +++ b/blockdag/fullblocktests/generate.go @@ -509,13 +509,12 @@ func (g *testGenerator) nextBlock(blockName string, spend *spendableOut, mungers block := wire.MsgBlock{ Header: wire.BlockHeader{ - Version: 1, - NumParentBlocks: 1, // TODO: (Stas) This is wrong. Modified only to satisfy compilation. - ParentHashes: []daghash.Hash{g.tip.BlockHash()}, // TODO: (Stas) This is wrong. Modified only to satisfy compilation. - MerkleRoot: calcMerkleRoot(txns), - Bits: g.params.PowLimitBits, - Timestamp: ts, - Nonce: 0, // To be solved. + Version: 1, + ParentHashes: []daghash.Hash{g.tip.BlockHash()}, // TODO: (Stas) This is wrong. Modified only to satisfy compilation. + MerkleRoot: calcMerkleRoot(txns), + Bits: g.params.PowLimitBits, + Timestamp: ts, + Nonce: 0, // To be solved. }, Transactions: txns, } diff --git a/blockdag/fullblocktests/params.go b/blockdag/fullblocktests/params.go index 66a69624b..a9528b2d4 100644 --- a/blockdag/fullblocktests/params.go +++ b/blockdag/fullblocktests/params.go @@ -54,13 +54,12 @@ var ( // as the public transaction ledger for the regression test network. regTestGenesisBlock = wire.MsgBlock{ Header: wire.BlockHeader{ - Version: 1, - NumParentBlocks: 0, - ParentHashes: []daghash.Hash{}, - MerkleRoot: *newHashFromStr("4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b"), - Timestamp: time.Unix(0x5b28c636, 0), // 2018-06-19 09:00:38 +0000 UTC - Bits: 0x207fffff, // 545259519 [7fffff0000000000000000000000000000000000000000000000000000000000] - Nonce: 1, + Version: 1, + ParentHashes: []daghash.Hash{}, + MerkleRoot: *newHashFromStr("4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b"), + Timestamp: time.Unix(0x5b28c636, 0), // 2018-06-19 09:00:38 +0000 UTC + Bits: 0x207fffff, // 545259519 [7fffff0000000000000000000000000000000000000000000000000000000000] + Nonce: 1, }, Transactions: []*wire.MsgTx{{ Version: 1, diff --git a/blockdag/validate.go b/blockdag/validate.go index b2a8a3d56..6670a8782 100644 --- a/blockdag/validate.go +++ b/blockdag/validate.go @@ -431,7 +431,7 @@ func checkBlockHeaderSanity(header *wire.BlockHeader, powLimit *big.Int, timeSou //checkBlockParentsOrder ensures that the block's parents are ordered by hash func checkBlockParentsOrder(header *wire.BlockHeader) error { - sortedHashes := make([]daghash.Hash, 0, len(header.ParentHashes)) + sortedHashes := make([]daghash.Hash, 0, header.NumParentBlocks()) for _, hash := range header.ParentHashes { sortedHashes = append(sortedHashes, hash) } diff --git a/blockdag/validate_test.go b/blockdag/validate_test.go index c3642f24f..a5264c155 100644 --- a/blockdag/validate_test.go +++ b/blockdag/validate_test.go @@ -169,8 +169,7 @@ func TestCheckBlockSanity(t *testing.T) { var invalidParentsOrderBlock = wire.MsgBlock{ Header: wire.BlockHeader{ - Version: 1, - NumParentBlocks: 2, + Version: 1, ParentHashes: []daghash.Hash{ [32]byte{ // Make go vet happy. 0x4b, 0xb0, 0x75, 0x35, 0xdf, 0xd5, 0x8e, 0x0b, @@ -610,8 +609,7 @@ func TestValidateParents(t *testing.T) { // test Block operations. var Block100000 = wire.MsgBlock{ Header: wire.BlockHeader{ - Version: 1, - NumParentBlocks: 2, + Version: 1, ParentHashes: []daghash.Hash{ [32]byte{ // Make go vet happy. 0x16, 0x5e, 0x38, 0xe8, 0xb3, 0x91, 0x45, 0x95, diff --git a/dagconfig/genesis.go b/dagconfig/genesis.go index 48feaa653..5e3c871be 100644 --- a/dagconfig/genesis.go +++ b/dagconfig/genesis.go @@ -78,13 +78,12 @@ var genesisMerkleRoot = daghash.Hash([daghash.HashSize]byte{ // Make go vet happ // public transaction ledger for the main network. var genesisBlock = wire.MsgBlock{ Header: wire.BlockHeader{ - Version: 1, - NumParentBlocks: 0, - ParentHashes: []daghash.Hash{}, - MerkleRoot: genesisMerkleRoot, // 4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b - Timestamp: time.Unix(0x5bbe076c, 0), // 2018-10-10 14:06:36 +0000 UTC - Bits: 0x1e00ffff, // 503382015 [000000ffff000000000000000000000000000000000000000000000000000000] - Nonce: 0x80000000000d8796, // 9223372036855662486 + Version: 1, + ParentHashes: []daghash.Hash{}, + MerkleRoot: genesisMerkleRoot, // 4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b + Timestamp: time.Unix(0x5bbe076c, 0), // 2018-10-10 14:06:36 +0000 UTC + Bits: 0x1e00ffff, // 503382015 [000000ffff000000000000000000000000000000000000000000000000000000] + Nonce: 0x80000000000d8796, // 9223372036855662486 }, Transactions: []*wire.MsgTx{&genesisCoinbaseTx}, } @@ -107,13 +106,12 @@ var regTestGenesisMerkleRoot = genesisMerkleRoot // as the public transaction ledger for the regression test network. var regTestGenesisBlock = wire.MsgBlock{ Header: wire.BlockHeader{ - Version: 1, - NumParentBlocks: 0, - ParentHashes: []daghash.Hash{}, - MerkleRoot: regTestGenesisMerkleRoot, // 4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b - Timestamp: time.Unix(0x5bbe0d4b, 0), // 2018-06-19 09:00:38 +0000 UTC - Bits: 0x207fffff, // 545259519 [7fffff0000000000000000000000000000000000000000000000000000000000] - Nonce: 0x00000000, + Version: 1, + ParentHashes: []daghash.Hash{}, + MerkleRoot: regTestGenesisMerkleRoot, // 4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b + Timestamp: time.Unix(0x5bbe0d4b, 0), // 2018-06-19 09:00:38 +0000 UTC + Bits: 0x207fffff, // 545259519 [7fffff0000000000000000000000000000000000000000000000000000000000] + Nonce: 0x00000000, }, Transactions: []*wire.MsgTx{&genesisCoinbaseTx}, } @@ -136,13 +134,12 @@ var testNet3GenesisMerkleRoot = genesisMerkleRoot // serves as the public transaction ledger for the test network (version 3). var testNet3GenesisBlock = wire.MsgBlock{ Header: wire.BlockHeader{ - Version: 1, - NumParentBlocks: 0, - ParentHashes: []daghash.Hash{}, - MerkleRoot: testNet3GenesisMerkleRoot, // 4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b - Timestamp: time.Unix(0x5bbe0e49, 0), // 2018-06-19 09:04:06 +0000 UTC - Bits: 0x1e00ffff, // 503382015 [000000ffff000000000000000000000000000000000000000000000000000000] - Nonce: 0xc00000000032560b, // 2150570811 + Version: 1, + ParentHashes: []daghash.Hash{}, + MerkleRoot: testNet3GenesisMerkleRoot, // 4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b + Timestamp: time.Unix(0x5bbe0e49, 0), // 2018-06-19 09:04:06 +0000 UTC + Bits: 0x1e00ffff, // 503382015 [000000ffff000000000000000000000000000000000000000000000000000000] + Nonce: 0xc00000000032560b, // 2150570811 }, Transactions: []*wire.MsgTx{&genesisCoinbaseTx}, } @@ -165,13 +162,12 @@ var simNetGenesisMerkleRoot = genesisMerkleRoot // as the public transaction ledger for the simulation test network. var simNetGenesisBlock = wire.MsgBlock{ Header: wire.BlockHeader{ - Version: 1, - NumParentBlocks: 0, - ParentHashes: []daghash.Hash{}, - MerkleRoot: simNetGenesisMerkleRoot, // 4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b - Timestamp: time.Unix(0x5bbe00fe, 0), // 2018-10-10 13:39:10 +0000 UTC - Bits: 0x207fffff, // 545259519 [7fffff0000000000000000000000000000000000000000000000000000000000] - Nonce: 0xdffffffffffffffc, // 1610612733 + Version: 1, + ParentHashes: []daghash.Hash{}, + MerkleRoot: simNetGenesisMerkleRoot, // 4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b + Timestamp: time.Unix(0x5bbe00fe, 0), // 2018-10-10 13:39:10 +0000 UTC + Bits: 0x207fffff, // 545259519 [7fffff0000000000000000000000000000000000000000000000000000000000] + Nonce: 0xdffffffffffffffc, // 1610612733 }, Transactions: []*wire.MsgTx{&genesisCoinbaseTx}, } diff --git a/database/testdata/generator.go b/database/testdata/generator.go index 5ec903073..87280ce5e 100644 --- a/database/testdata/generator.go +++ b/database/testdata/generator.go @@ -44,13 +44,12 @@ func generateBlocks(out *os.File, numBlocks int) { func generateBlock(parent *wire.MsgBlock) *wire.MsgBlock { return &wire.MsgBlock{ Header: wire.BlockHeader{ - Version: 1, - NumParentBlocks: 1, - ParentHashes: []daghash.Hash{parent.BlockHash()}, - MerkleRoot: genesisMerkleRoot, - Timestamp: time.Unix(0x5b28c4c8, 0), // 2018-06-19 08:54:32 +0000 UTC - Bits: 0x1e00ffff, // 503382015 [000000ffff000000000000000000000000000000000000000000000000000000] - Nonce: 0xc0192550, // 2148484547 + Version: 1, + ParentHashes: []daghash.Hash{parent.BlockHash()}, + MerkleRoot: genesisMerkleRoot, + Timestamp: time.Unix(0x5b28c4c8, 0), // 2018-06-19 08:54:32 +0000 UTC + Bits: 0x1e00ffff, // 503382015 [000000ffff000000000000000000000000000000000000000000000000000000] + Nonce: 0xc0192550, // 2148484547 }, Transactions: []*wire.MsgTx{&genesisCoinbaseTx}, } diff --git a/mining/mining.go b/mining/mining.go index e67449591..1771b1f84 100644 --- a/mining/mining.go +++ b/mining/mining.go @@ -715,12 +715,11 @@ mempoolLoop: merkles := blockdag.BuildMerkleTreeStore(blockTxns) var msgBlock wire.MsgBlock msgBlock.Header = wire.BlockHeader{ - Version: nextBlockVersion, - NumParentBlocks: byte(len(g.dag.TipHashes())), - ParentHashes: g.dag.TipHashes(), - MerkleRoot: *merkles[len(merkles)-1], - Timestamp: ts, - Bits: reqDifficulty, + Version: nextBlockVersion, + ParentHashes: g.dag.TipHashes(), + MerkleRoot: *merkles[len(merkles)-1], + Timestamp: ts, + Bits: reqDifficulty, } for _, tx := range blockTxns { if err := msgBlock.AddTransaction(tx.MsgTx()); err != nil { diff --git a/util/block_test.go b/util/block_test.go index 486e5d276..ae7bb5c72 100644 --- a/util/block_test.go +++ b/util/block_test.go @@ -304,8 +304,7 @@ func TestBlockErrors(t *testing.T) { // test Block operations. var Block100000 = wire.MsgBlock{ Header: wire.BlockHeader{ - Version: 1, - NumParentBlocks: 2, + Version: 1, ParentHashes: []daghash.Hash{ [32]byte{ // Make go vet happy. 0x82, 0xdc, 0xbd, 0xe6, 0x88, 0x37, 0x74, 0x5b, diff --git a/wire/blockheader.go b/wire/blockheader.go index 1a1a90611..8aa097022 100644 --- a/wire/blockheader.go +++ b/wire/blockheader.go @@ -34,9 +34,6 @@ type BlockHeader struct { // Version of the block. This is not the same as the protocol version. Version int32 - // Number of entries in ParentHashes - NumParentBlocks byte - // Hashes of the parent block headers in the blockDAG. ParentHashes []daghash.Hash @@ -53,13 +50,18 @@ type BlockHeader struct { Nonce uint64 } +// NumParentBlocks return the number of entries in ParentHashes +func (h *BlockHeader) NumParentBlocks() byte { + return byte(len(h.ParentHashes)) +} + // BlockHash computes the block identifier hash for the given block header. func (h *BlockHeader) BlockHash() daghash.Hash { // Encode the header and double sha256 everything prior to the number of // transactions. Ignore the error returns since there is no way the // encode could fail except being out of memory which would cause a // run-time panic. - buf := bytes.NewBuffer(make([]byte, 0, BaseBlockHeaderPayload+len(h.ParentHashes))) + buf := bytes.NewBuffer(make([]byte, 0, BaseBlockHeaderPayload+h.NumParentBlocks())) _ = writeBlockHeader(buf, 0, h) return daghash.DoubleHashH(buf.Bytes()) @@ -67,7 +69,7 @@ func (h *BlockHeader) BlockHash() daghash.Hash { // SelectedParentHash returns the hash of the selected block header. func (h *BlockHeader) SelectedParentHash() *daghash.Hash { - if h.NumParentBlocks == 0 { + if h.NumParentBlocks() == 0 { return nil } @@ -76,7 +78,7 @@ func (h *BlockHeader) SelectedParentHash() *daghash.Hash { // IsGenesis returns true iff this block is a genesis block func (h *BlockHeader) IsGenesis() bool { - return h.NumParentBlocks == 0 + return h.NumParentBlocks() == 0 } // BtcDecode decodes r using the bitcoin protocol encoding into the receiver. @@ -118,7 +120,7 @@ func (h *BlockHeader) Serialize(w io.Writer) error { // SerializeSize returns the number of bytes it would take to serialize the // block header. func (h *BlockHeader) SerializeSize() int { - return BaseBlockHeaderPayload + int(h.NumParentBlocks)*daghash.HashSize + return BaseBlockHeaderPayload + int(h.NumParentBlocks())*daghash.HashSize } // NewBlockHeader returns a new BlockHeader using the provided version, previous @@ -130,13 +132,12 @@ func NewBlockHeader(version int32, parentHashes []daghash.Hash, merkleRootHash * // Limit the timestamp to one second precision since the protocol // doesn't support better. return &BlockHeader{ - Version: version, - NumParentBlocks: byte(len(parentHashes)), - ParentHashes: parentHashes, - MerkleRoot: *merkleRootHash, - Timestamp: time.Unix(time.Now().Unix(), 0), - Bits: bits, - Nonce: nonce, + Version: version, + ParentHashes: parentHashes, + MerkleRoot: *merkleRootHash, + Timestamp: time.Unix(time.Now().Unix(), 0), + Bits: bits, + Nonce: nonce, } } @@ -144,13 +145,14 @@ func NewBlockHeader(version int32, parentHashes []daghash.Hash, merkleRootHash * // decoding block headers stored to disk, such as in a database, as opposed to // decoding from the wire. func readBlockHeader(r io.Reader, pver uint32, bh *BlockHeader) error { - err := readElements(r, &bh.Version, &bh.NumParentBlocks) + var numParentBlocks byte + err := readElements(r, &bh.Version, &numParentBlocks) if err != nil { return err } - bh.ParentHashes = make([]daghash.Hash, bh.NumParentBlocks) - for i := byte(0); i < bh.NumParentBlocks; i++ { + bh.ParentHashes = make([]daghash.Hash, numParentBlocks) + for i := byte(0); i < numParentBlocks; i++ { err := readElement(r, &bh.ParentHashes[i]) if err != nil { return err @@ -164,6 +166,6 @@ func readBlockHeader(r io.Reader, pver uint32, bh *BlockHeader) error { // opposed to encoding for the wire. func writeBlockHeader(w io.Writer, pver uint32, bh *BlockHeader) error { sec := int64(bh.Timestamp.Unix()) - return writeElements(w, bh.Version, bh.NumParentBlocks, &bh.ParentHashes, &bh.MerkleRoot, + return writeElements(w, bh.Version, bh.NumParentBlocks(), &bh.ParentHashes, &bh.MerkleRoot, sec, bh.Bits, bh.Nonce) } diff --git a/wire/blockheader_test.go b/wire/blockheader_test.go index e448c7c93..bd9dc0254 100644 --- a/wire/blockheader_test.go +++ b/wire/blockheader_test.go @@ -55,13 +55,12 @@ func TestBlockHeaderWire(t *testing.T) { // baseBlockHdr is used in the various tests as a baseline BlockHeader. bits := uint32(0x1d00ffff) baseBlockHdr := &BlockHeader{ - Version: 1, - NumParentBlocks: 2, - ParentHashes: []daghash.Hash{mainNetGenesisHash, simNetGenesisHash}, - MerkleRoot: mainNetGenesisMerkleRoot, - Timestamp: time.Unix(0x495fab29, 0), // 2009-01-03 12:15:05 -0600 CST - Bits: bits, - Nonce: nonce, + Version: 1, + ParentHashes: []daghash.Hash{mainNetGenesisHash, simNetGenesisHash}, + MerkleRoot: mainNetGenesisMerkleRoot, + Timestamp: time.Unix(0x495fab29, 0), // 2009-01-03 12:15:05 -0600 CST + Bits: bits, + Nonce: nonce, } // baseBlockHdrEncoded is the wire encoded bytes of baseBlockHdr. @@ -194,13 +193,12 @@ func TestBlockHeaderSerialize(t *testing.T) { // baseBlockHdr is used in the various tests as a baseline BlockHeader. bits := uint32(0x1d00ffff) baseBlockHdr := &BlockHeader{ - Version: 1, - NumParentBlocks: 2, - ParentHashes: []daghash.Hash{mainNetGenesisHash, simNetGenesisHash}, - MerkleRoot: mainNetGenesisMerkleRoot, - Timestamp: time.Unix(0x495fab29, 0), // 2009-01-03 12:15:05 -0600 CST - Bits: bits, - Nonce: nonce, + Version: 1, + ParentHashes: []daghash.Hash{mainNetGenesisHash, simNetGenesisHash}, + MerkleRoot: mainNetGenesisMerkleRoot, + Timestamp: time.Unix(0x495fab29, 0), // 2009-01-03 12:15:05 -0600 CST + Bits: bits, + Nonce: nonce, } // baseBlockHdrEncoded is the wire encoded bytes of baseBlockHdr. @@ -274,23 +272,21 @@ func TestBlockHeaderSerializeSize(t *testing.T) { bits := uint32(0x1d00ffff) timestamp := time.Unix(0x495fab29, 0) // 2009-01-03 12:15:05 -0600 CST baseBlockHdr := &BlockHeader{ - Version: 1, - NumParentBlocks: 2, - ParentHashes: []daghash.Hash{mainNetGenesisHash, simNetGenesisHash}, - MerkleRoot: mainNetGenesisMerkleRoot, - Timestamp: timestamp, - Bits: bits, - Nonce: nonce, + Version: 1, + ParentHashes: []daghash.Hash{mainNetGenesisHash, simNetGenesisHash}, + MerkleRoot: mainNetGenesisMerkleRoot, + Timestamp: timestamp, + Bits: bits, + Nonce: nonce, } genesisBlockHdr := &BlockHeader{ - Version: 1, - NumParentBlocks: 0, - ParentHashes: []daghash.Hash{}, - MerkleRoot: mainNetGenesisMerkleRoot, - Timestamp: timestamp, - Bits: bits, - Nonce: nonce, + Version: 1, + ParentHashes: []daghash.Hash{}, + MerkleRoot: mainNetGenesisMerkleRoot, + Timestamp: timestamp, + Bits: bits, + Nonce: nonce, } tests := []struct { in *BlockHeader // Block header to encode @@ -321,22 +317,20 @@ func TestIsGenesis(t *testing.T) { timestamp := time.Unix(0x495fab29, 0) // 2009-01-03 12:15:05 -0600 CST baseBlockHdr := &BlockHeader{ - Version: 1, - NumParentBlocks: 2, - ParentHashes: []daghash.Hash{mainNetGenesisHash, simNetGenesisHash}, - MerkleRoot: mainNetGenesisMerkleRoot, - Timestamp: timestamp, - Bits: bits, - Nonce: nonce, + Version: 1, + ParentHashes: []daghash.Hash{mainNetGenesisHash, simNetGenesisHash}, + MerkleRoot: mainNetGenesisMerkleRoot, + Timestamp: timestamp, + Bits: bits, + Nonce: nonce, } genesisBlockHdr := &BlockHeader{ - Version: 1, - NumParentBlocks: 0, - ParentHashes: []daghash.Hash{}, - MerkleRoot: mainNetGenesisMerkleRoot, - Timestamp: timestamp, - Bits: bits, - Nonce: nonce, + Version: 1, + ParentHashes: []daghash.Hash{}, + MerkleRoot: mainNetGenesisMerkleRoot, + Timestamp: timestamp, + Bits: bits, + Nonce: nonce, } tests := []struct { diff --git a/wire/msgblock_test.go b/wire/msgblock_test.go index 2bbe30a90..bfc600ba7 100644 --- a/wire/msgblock_test.go +++ b/wire/msgblock_test.go @@ -491,10 +491,9 @@ func TestBlockSerializeSize(t *testing.T) { // blockOne is the first block in the mainnet block chain. var blockOne = MsgBlock{ Header: BlockHeader{ - Version: 1, - NumParentBlocks: 2, - ParentHashes: []daghash.Hash{mainNetGenesisHash, simNetGenesisHash}, - MerkleRoot: daghash.Hash(mainNetGenesisMerkleRoot), + Version: 1, + ParentHashes: []daghash.Hash{mainNetGenesisHash, simNetGenesisHash}, + MerkleRoot: daghash.Hash(mainNetGenesisMerkleRoot), Timestamp: time.Unix(0x4966bc61, 0), // 2009-01-08 20:54:25 -0600 CST Bits: 0x1d00ffff, // 486604799 diff --git a/wire/msgmerkleblock_test.go b/wire/msgmerkleblock_test.go index 5ba44c6b3..4948050bf 100644 --- a/wire/msgmerkleblock_test.go +++ b/wire/msgmerkleblock_test.go @@ -337,9 +337,8 @@ func TestMerkleBlockOverflowErrors(t *testing.T) { // where the first transaction matches. var merkleBlockOne = MsgMerkleBlock{ Header: BlockHeader{ - Version: 1, - NumParentBlocks: 2, - ParentHashes: []daghash.Hash{mainNetGenesisHash, simNetGenesisHash}, + Version: 1, + ParentHashes: []daghash.Hash{mainNetGenesisHash, simNetGenesisHash}, MerkleRoot: daghash.Hash([daghash.HashSize]byte{ // Make go vet happy. 0x98, 0x20, 0x51, 0xfd, 0x1e, 0x4b, 0xa7, 0x44, 0xbb, 0xbe, 0x68, 0x0e, 0x1f, 0xee, 0x14, 0x67,