diff --git a/blockdag/fullblocktests/generate.go b/blockdag/fullblocktests/generate.go index 7803c6a58..38fc44aa5 100644 --- a/blockdag/fullblocktests/generate.go +++ b/blockdag/fullblocktests/generate.go @@ -606,7 +606,8 @@ func (g *testGenerator) saveSpendableCoinbaseOuts() { // reaching the block that has already had the coinbase outputs // collected. var collectBlocks []*wire.MsgBlock - for b := g.tip; b != nil; b = g.blocks[*b.Header.SelectedParentHash()] { + // TODO: (Evgeny) This is wrong. Modified only to satisfy compilation. + for b := g.tip; b != nil; b = g.blocks[*b.Header.ParentHashes[0]] { if b.BlockHash() == g.prevCollectedHash { break } @@ -1553,9 +1554,11 @@ func Generate(includeLargeReorg bool) (tests [][]TestInstance, err error) { // ... -> b33(9) -> b35(10) -> b39(11) -> b42(12) -> b43(13) -> b53(14) // \-> b54(15) g.nextBlock("b54", outs[15], func(b *wire.MsgBlock) { - medianBlock := g.blocks[*b.Header.SelectedParentHash()] + // TODO: (Evgeny) This is wrong. Modified only to satisfy compilation. + medianBlock := g.blocks[*b.Header.ParentHashes[0]] for i := 0; i < medianTimeBlocks/2; i++ { - medianBlock = g.blocks[*medianBlock.Header.SelectedParentHash()] + // TODO: (Evgeny) This is wrong. Modified only to satisfy compilation. + medianBlock = g.blocks[*medianBlock.Header.ParentHashes[0]] } b.Header.Timestamp = medianBlock.Header.Timestamp }) @@ -1567,9 +1570,11 @@ func Generate(includeLargeReorg bool) (tests [][]TestInstance, err error) { // ... -> b33(9) -> b35(10) -> b39(11) -> b42(12) -> b43(13) -> b53(14) -> b55(15) g.setTip("b53") g.nextBlock("b55", outs[15], func(b *wire.MsgBlock) { - medianBlock := g.blocks[*b.Header.SelectedParentHash()] + // TODO: (Evgeny) This is wrong. Modified only to satisfy compilation. + medianBlock := g.blocks[*b.Header.ParentHashes[0]] for i := 0; i < medianTimeBlocks/2; i++ { - medianBlock = g.blocks[*medianBlock.Header.SelectedParentHash()] + // TODO: (Evgeny) This is wrong. Modified only to satisfy compilation. + medianBlock = g.blocks[*medianBlock.Header.ParentHashes[0]] } medianBlockTime := medianBlock.Header.Timestamp b.Header.Timestamp = medianBlockTime.Add(time.Second) @@ -1717,7 +1722,8 @@ func Generate(includeLargeReorg bool) (tests [][]TestInstance, err error) { g.nextBlock("b61", outs[18], func(b *wire.MsgBlock) { // Duplicate the coinbase of the parent block to force the // condition. - parent := g.blocks[*b.Header.SelectedParentHash()] + // TODO: (Evgeny) This is wrong. Modified only to satisfy compilation. + parent := g.blocks[*b.Header.ParentHashes[0]] b.Transactions[0] = parent.Transactions[0] }) rejected(blockdag.ErrOverwriteTx) diff --git a/blockdag/indexers/cfindex.go b/blockdag/indexers/cfindex.go index ef8021bff..ecf31d40e 100644 --- a/blockdag/indexers/cfindex.go +++ b/blockdag/indexers/cfindex.go @@ -176,14 +176,19 @@ func storeFilter(dbTx database.Tx, block *util.Block, f *gcs.Filter, if header.IsGenesis() { prevHeader = &daghash.ZeroHash } else { - ph := header.SelectedParentHash() - pfh, err := dbFetchFilterIdxEntry(dbTx, hkey, ph) + // TODO(Evgeny): Current implementation of GCS filter inherited from chain + // (single parent) and must be ported to DAG (multiple parents) + var parentHash *daghash.Hash + if header.NumParentBlocks() != 0 { + parentHash = header.ParentHashes[0] + } + prevFilterHashBytes, err := dbFetchFilterIdxEntry(dbTx, hkey, parentHash) if err != nil { return err } // Construct the new block's filter header, and store it. - prevHeader, err = daghash.NewHash(pfh) + prevHeader, err = daghash.NewHash(prevFilterHashBytes) if err != nil { return err } diff --git a/wire/blockheader.go b/wire/blockheader.go index 7d3286687..54e752065 100644 --- a/wire/blockheader.go +++ b/wire/blockheader.go @@ -70,15 +70,6 @@ func (h *BlockHeader) BlockHash() *daghash.Hash { return daghash.DoubleHashP(buf.Bytes()) } -// SelectedParentHash returns the hash of the selected block header. -func (h *BlockHeader) SelectedParentHash() *daghash.Hash { - if h.NumParentBlocks() == 0 { - return nil - } - - return h.ParentHashes[0] -} - // IsGenesis returns true iff this block is a genesis block func (h *BlockHeader) IsGenesis() bool { return h.NumParentBlocks() == 0