[DEV-34] Made a bunch of modifications just to satisfy the compiler.

This commit is contained in:
Stas Boutenko 2018-06-24 11:37:31 +03:00
parent e1e6d7e0b8
commit b0d766b7ab
17 changed files with 88 additions and 77 deletions

View File

@ -235,7 +235,7 @@ func (b *BlockChain) GetOrphanRoot(hash *daghash.Hash) *daghash.Hash {
break
}
orphanRoot = prevHash
prevHash = &orphan.block.MsgBlock().Header.PrevBlock
prevHash = &orphan.block.MsgBlock().Header.PrevBlocks[0] // TODO: (Stas) This is wrong. Modified only to satisfy compilation.
}
return orphanRoot
@ -256,7 +256,7 @@ func (b *BlockChain) removeOrphanBlock(orphan *orphanBlock) {
// for loop is intentionally used over a range here as range does not
// reevaluate the slice on each iteration nor does it adjust the index
// for the modified slice.
prevHash := &orphan.block.MsgBlock().Header.PrevBlock
prevHash := &orphan.block.MsgBlock().Header.PrevBlocks[0] // TODO: (Stas) This is wrong. Modified only to satisfy compilation.
orphans := b.prevOrphans[*prevHash]
for i := 0; i < len(orphans); i++ {
hash := orphans[i].block.Hash()
@ -320,7 +320,7 @@ func (b *BlockChain) addOrphanBlock(block *btcutil.Block) {
b.orphans[*block.Hash()] = oBlock
// Add to previous hash lookup index for faster dependency lookups.
prevHash := &block.MsgBlock().Header.PrevBlock
prevHash := &block.MsgBlock().Header.PrevBlocks[0] // TODO: (Stas) This is wrong. Modified only to satisfy compilation.
b.prevOrphans[*prevHash] = append(b.prevOrphans[*prevHash], oBlock)
}
@ -373,7 +373,7 @@ func (b *BlockChain) calcSequenceLock(node *blockNode, tx *btcutil.Tx, utxoView
// Obtain the latest BIP9 version bits state for the
// CSV-package soft-fork deployment. The adherence of sequence
// locks depends on the current soft-fork state.
csvState, err := b.deploymentState(node.parent, dagconfig.DeploymentCSV)
csvState, err := b.deploymentState(&node.parents[0], dagconfig.DeploymentCSV) // TODO: (Stas) This is wrong. Modified only to satisfy compilation.
if err != nil {
return nil, err
}
@ -502,7 +502,7 @@ func (b *BlockChain) getReorganizeNodes(node *blockNode) (*list.List, *list.List
// Do not reorganize to a known invalid chain. Ancestors deeper than the
// direct parent are checked below but this is a quick check before doing
// more unnecessary work.
if b.index.NodeStatus(node.parent).KnownInvalid() {
if b.index.NodeStatus(&node.parents[0]).KnownInvalid() { // TODO: (Stas) This is wrong. Modified only to satisfy compilation.
b.index.SetStatusFlags(node, statusInvalidAncestor)
return detachNodes, attachNodes
}
@ -513,7 +513,7 @@ func (b *BlockChain) getReorganizeNodes(node *blockNode) (*list.List, *list.List
// later.
forkNode := b.bestChain.FindFork(node)
invalidChain := false
for n := node; n != nil && n != forkNode; n = n.parent {
for n := node; n != nil && n != forkNode; n = &n.parents[0] { // TODO: (Stas) This is wrong. Modified only to satisfy compilation.
if b.index.NodeStatus(n).KnownInvalid() {
invalidChain = true
break
@ -536,7 +536,7 @@ func (b *BlockChain) getReorganizeNodes(node *blockNode) (*list.List, *list.List
// Start from the end of the main chain and work backwards until the
// common ancestor adding each block to the list of nodes to detach from
// the main chain.
for n := b.bestChain.Tip(); n != nil && n != forkNode; n = n.parent {
for n := b.bestChain.Tip(); n != nil && n != forkNode; n = &n.parents[0] { // TODO: (Stas) This is wrong. Modified only to satisfy compilation.
detachNodes.PushBack(n)
}
@ -556,7 +556,7 @@ func (b *BlockChain) getReorganizeNodes(node *blockNode) (*list.List, *list.List
// This function MUST be called with the chain state lock held (for writes).
func (b *BlockChain) connectBlock(node *blockNode, block *btcutil.Block, view *UtxoViewpoint, stxos []spentTxOut) error {
// Make sure it's extending the end of the best chain.
prevHash := &block.MsgBlock().Header.PrevBlock
prevHash := &block.MsgBlock().Header.PrevBlocks[0] // TODO: (Stas) This is wrong. Modified only to satisfy compilation.
if !prevHash.IsEqual(&b.bestChain.Tip().hash) {
return AssertError("connectBlock must be called with a block " +
"that extends the main chain")
@ -684,7 +684,7 @@ func (b *BlockChain) disconnectBlock(node *blockNode, block *btcutil.Block, view
}
// Load the previous block since some details for it are needed below.
prevNode := node.parent
prevNode := &node.parents[0] // TODO: (Stas) This is wrong. Modified only to satisfy compilation.
var prevBlock *btcutil.Block
err := b.db.View(func(dbTx database.Tx) error {
var err error
@ -762,7 +762,7 @@ func (b *BlockChain) disconnectBlock(node *blockNode, block *btcutil.Block, view
view.commit()
// This node's parent is now the end of the best chain.
b.bestChain.SetTip(node.parent)
b.bestChain.SetTip(&node.parents[0]) // TODO: (Stas) This is wrong. Modified only to satisfy compilation.
// Update the state for the best block. Notice how this replaces the
// entire struct instead of updating the existing one. This effectively
@ -1003,7 +1003,7 @@ func (b *BlockChain) reorganizeChain(detachNodes, attachNodes *list.List) error
firstAttachNode := attachNodes.Front().Value.(*blockNode)
firstDetachNode := detachNodes.Front().Value.(*blockNode)
lastAttachNode := attachNodes.Back().Value.(*blockNode)
log.Infof("REORGANIZE: Chain forks at %v", firstAttachNode.parent.hash)
log.Infof("REORGANIZE: Chain forks at %v", firstAttachNode.parents[0].hash) // TODO: (Stas) This is wrong. Modified only to satisfy compilation.
log.Infof("REORGANIZE: Old best chain head was %v", firstDetachNode.hash)
log.Infof("REORGANIZE: New best chain head is %v", lastAttachNode.hash)
@ -1029,7 +1029,7 @@ func (b *BlockChain) connectBestChain(node *blockNode, block *btcutil.Block, fla
// We are extending the main (best) chain with a new block. This is the
// most common case.
parentHash := &block.MsgBlock().Header.PrevBlock
parentHash := &block.MsgBlock().Header.PrevBlocks[0] // TODO: (Stas) This is wrong. Modified only to satisfy compilation.
if parentHash.IsEqual(&b.bestChain.Tip().hash) {
// Skip checks if node has already been fully validated.
fastAdd = fastAdd || b.index.NodeStatus(node).KnownValid()
@ -1355,7 +1355,7 @@ func (b *BlockChain) HeightToHashRange(startHeight int32,
hashes := make([]daghash.Hash, resultsLength)
for i := resultsLength - 1; i >= 0; i-- {
hashes[i] = node.hash
node = node.parent
node = &node.parents[0] // TODO: (Stas) This is wrong. Modified only to satisfy compilation.
}
return hashes, nil
}

View File

@ -1146,13 +1146,13 @@ func (b *BlockChain) initChainState() error {
"first entry in block index to be genesis block, "+
"found %s", blockHash))
}
} else if header.PrevBlock == lastNode.hash {
} else if header.PrevBlocks[0] == lastNode.hash { // TODO: (Stas) This is wrong. Modified only to satisfy compilation.
// Since we iterate block headers in order of height, if the
// blocks are mostly linear there is a very good chance the
// previous header processed is the parent.
parent = lastNode
} else {
parent = b.index.LookupNode(&header.PrevBlock)
parent = b.index.LookupNode(&header.PrevBlocks[0]) // TODO: (Stas) This is wrong. Modified only to satisfy compilation.
if parent == nil {
return AssertError(fmt.Sprintf("initChainState: Could "+
"not find parent for block %s", header.BlockHash()))
@ -1162,7 +1162,7 @@ func (b *BlockChain) initChainState() error {
// Initialize the block node for the block, connect it,
// and add it to the block index.
node := &blockNodes[i]
initBlockNode(node, header, parent)
initBlockNode(node, header, []blockNode{*parent}) // TODO: (Stas) This is wrong. Modified only to satisfy compilation.
node.status = status
b.index.addNode(node)

View File

@ -141,7 +141,7 @@ func (c *chainView) setTip(node *blockNode) {
for node != nil && c.nodes[node.height] != node {
c.nodes[node.height] = node
node = node.parent
node = &node.parents[0] // TODO: (Stas) This is wrong. Modified only to satisfy compilation.
}
}
@ -311,7 +311,7 @@ func (c *chainView) findFork(node *blockNode) *blockNode {
// contain the node or there are no more nodes in which case there is no
// common node between the two.
for node != nil && !c.contains(node) {
node = node.parent
node = &node.parents[0] // TODO: (Stas) This is wrong. Modified only to satisfy compilation.
}
return node

View File

@ -11,6 +11,7 @@ import (
"testing"
"github.com/daglabs/btcd/wire"
"github.com/daglabs/btcd/dagconfig/daghash"
)
// testNoncePrng provides a deterministic prng for the nonce in generated fake
@ -28,9 +29,9 @@ func chainedNodes(parent *blockNode, numNodes int) []*blockNode {
// synthetic tests to work.
header := wire.BlockHeader{Nonce: testNoncePrng.Uint32()}
if tip != nil {
header.PrevBlock = tip.hash
header.PrevBlocks = []daghash.Hash{tip.hash} // TODO: (Stas) This is wrong. Modified only to satisfy compilation.
}
nodes[i] = newBlockNode(&header, tip)
nodes[i] = newBlockNode(&header, []blockNode{*tip}) // TODO: (Stas) This is wrong. Modified only to satisfy compilation.
tip = nodes[i]
}
return nodes

View File

@ -234,14 +234,14 @@ func (b *BlockChain) IsCheckpointCandidate(block *btcutil.Block) (bool, error) {
}
// A checkpoint must be have at least one block before it.
if node.parent == nil {
if &node.parents[0] == nil { // TODO: (Stas) This is wrong. Modified only to satisfy compilation.
return false, nil
}
// A checkpoint must have timestamps for the block and the blocks on
// either side of it in order (due to the median time allowance this is
// not always the case).
prevTime := time.Unix(node.parent.timestamp, 0)
prevTime := time.Unix(node.parents[0].timestamp, 0) // TODO: (Stas) This is wrong. Modified only to satisfy compilation.
curTime := block.MsgBlock().Header.Timestamp
nextTime := time.Unix(nextNode.timestamp, 0)
if prevTime.After(curTime) || nextTime.Before(curTime) {

View File

@ -375,10 +375,10 @@ func newFakeChain(params *dagconfig.Params) *BlockChain {
func newFakeNode(parent *blockNode, blockVersion int32, bits uint32, timestamp time.Time) *blockNode {
// Make up a header and create a block node from it.
header := &wire.BlockHeader{
Version: blockVersion,
PrevBlock: parent.hash,
Bits: bits,
Timestamp: timestamp,
Version: blockVersion,
PrevBlocks: []daghash.Hash{parent.hash}, // TODO: (Stas) This is wrong. Modified only to satisfy compilation.
Bits: bits,
Timestamp: timestamp,
}
return newBlockNode(header, parent)
return newBlockNode(header, []blockNode{*parent}) // TODO: (Stas) This is wrong. Modified only to satisfy compilation.
}

View File

@ -201,7 +201,7 @@ func (b *BlockChain) findPrevTestNetDifficulty(startNode *blockNode) uint32 {
for iterNode != nil && iterNode.height%b.blocksPerRetarget != 0 &&
iterNode.bits == b.chainParams.PowLimitBits {
iterNode = iterNode.parent
iterNode = &iterNode.parents[0] // TODO: (Stas) This is wrong. Modified only to satisfy compilation.
}
// Return the found difficulty or the minimum difficulty if no

View File

@ -510,12 +510,13 @@ func (g *testGenerator) nextBlock(blockName string, spend *spendableOut, mungers
block := wire.MsgBlock{
Header: wire.BlockHeader{
Version: 1,
PrevBlock: g.tip.BlockHash(),
MerkleRoot: calcMerkleRoot(txns),
Bits: g.params.PowLimitBits,
Timestamp: ts,
Nonce: 0, // To be solved.
Version: 1,
NumPrevBlocks: 1, // TODO: (Stas) This is wrong. Modified only to satisfy compilation.
PrevBlocks: []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,
}
@ -607,7 +608,7 @@ 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.PrevBlock] {
for b := g.tip; b != nil; b = g.blocks[b.Header.PrevBlocks[0]] { // TODO: (Stas) This is wrong. Modified only to satisfy compilation.
if b.BlockHash() == g.prevCollectedHash {
break
}
@ -1555,9 +1556,9 @@ 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.PrevBlock]
medianBlock := g.blocks[b.Header.PrevBlocks[0]] // TODO: (Stas) This is wrong. Modified only to satisfy compilation.
for i := 0; i < medianTimeBlocks/2; i++ {
medianBlock = g.blocks[medianBlock.Header.PrevBlock]
medianBlock = g.blocks[medianBlock.Header.PrevBlocks[0]] // TODO: (Stas) This is wrong. Modified only to satisfy compilation.
}
b.Header.Timestamp = medianBlock.Header.Timestamp
})
@ -1569,9 +1570,9 @@ 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.PrevBlock]
medianBlock := g.blocks[b.Header.PrevBlocks[0]] // TODO: (Stas) This is wrong. Modified only to satisfy compilation.
for i := 0; i < medianTimeBlocks/2; i++ {
medianBlock = g.blocks[medianBlock.Header.PrevBlock]
medianBlock = g.blocks[medianBlock.Header.PrevBlocks[0]] // TODO: (Stas) This is wrong. Modified only to satisfy compilation.
}
medianBlockTime := medianBlock.Header.Timestamp
b.Header.Timestamp = medianBlockTime.Add(time.Second)
@ -1719,7 +1720,7 @@ 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.PrevBlock]
parent := g.blocks[b.Header.PrevBlocks[0]] // TODO: (Stas) This is wrong. Modified only to satisfy compilation.
b.Transactions[0] = parent.Transactions[0]
})
rejected(blockdag.ErrOverwriteTx)

View File

@ -51,12 +51,13 @@ var (
// as the public transaction ledger for the regression test network.
regTestGenesisBlock = wire.MsgBlock{
Header: wire.BlockHeader{
Version: 1,
PrevBlock: *newHashFromStr("0000000000000000000000000000000000000000000000000000000000000000"),
MerkleRoot: *newHashFromStr("4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b"),
Timestamp: time.Unix(1296688602, 0), // 2011-02-02 23:16:42 +0000 UTC
Bits: 0x207fffff, // 545259519 [7fffff0000000000000000000000000000000000000000000000000000000000]
Nonce: 2,
Version: 1,
NumPrevBlocks: 0,
PrevBlocks: []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,
@ -121,7 +122,7 @@ var regressionNetParams = &dagconfig.Params{
RelayNonStdTxs: true,
// Address encoding magics
PrivateKeyID: 0xef, // starts with 9 (uncompressed) or c (compressed)
PrivateKeyID: 0xef, // starts with 9 (uncompressed) or c (compressed)
// BIP32 hierarchical deterministic extended key magics
HDPrivateKeyID: [4]byte{0x04, 0x35, 0x83, 0x94}, // starts with tprv

View File

@ -175,7 +175,7 @@ func storeFilter(dbTx database.Tx, block *btcutil.Block, f *gcs.Filter,
// Then fetch the previous block's filter header.
var prevHeader *daghash.Hash
ph := &block.MsgBlock().Header.PrevBlock
ph := &block.MsgBlock().Header.PrevBlocks[0] // TODO: (Stas) This is wrong. Modified only to satisfy compilation.
if ph.IsEqual(&zeroHash) {
prevHeader = &zeroHash
} else {

View File

@ -76,7 +76,7 @@ func dbIndexConnectBlock(dbTx database.Tx, indexer Indexer, block *btcutil.Block
if err != nil {
return err
}
if !curTipHash.IsEqual(&block.MsgBlock().Header.PrevBlock) {
if !curTipHash.IsEqual(&block.MsgBlock().Header.PrevBlocks[0]) { // TODO: (Stas) This is wrong. Modified only to satisfy compilation.
return AssertError(fmt.Sprintf("dbIndexConnectBlock must be "+
"called with a block that extends the current index "+
"tip (%s, tip %s, block %s)", indexer.Name(),
@ -118,7 +118,7 @@ func dbIndexDisconnectBlock(dbTx database.Tx, indexer Indexer, block *btcutil.Bl
}
// Update the current index tip.
prevHash := &block.MsgBlock().Header.PrevBlock
prevHash := &block.MsgBlock().Header.PrevBlocks[0] // TODO: (Stas) This is wrong. Modified only to satisfy compilation.
return dbPutIndexerTip(dbTx, idxKey, prevHash, block.Height()-1)
}
@ -332,7 +332,7 @@ func (m *Manager) Init(chain *blockdag.BlockChain, interrupt <-chan struct{}) er
}
// Update the tip to the previous block.
hash = &block.MsgBlock().Header.PrevBlock
hash = &block.MsgBlock().Header.PrevBlocks[0] // TODO: (Stas) This is wrong. Modified only to satisfy compilation.
height--
return nil

View File

@ -230,7 +230,7 @@ func (b *BlockChain) thresholdState(prevNode *blockNode, checker thresholdCondit
}
// Get the previous block node.
countNode = countNode.parent
countNode = &countNode.parents[0] // TODO: (Stas) This is wrong. Modified only to satisfy compilation.
}
// The state is locked in if the number of blocks in the
@ -245,8 +245,8 @@ func (b *BlockChain) thresholdState(prevNode *blockNode, checker thresholdCondit
// was locked in.
state = ThresholdActive
// Nothing to do if the previous state is active or failed since
// they are both terminal states.
// Nothing to do if the previous state is active or failed since
// they are both terminal states.
case ThresholdActive:
case ThresholdFailed:
}
@ -316,7 +316,7 @@ func (b *BlockChain) initThresholdCaches() error {
// threshold state for each of them. This will ensure the caches are
// populated and any states that needed to be recalculated due to
// definition changes is done now.
prevNode := b.bestChain.Tip().parent
prevNode := &b.bestChain.Tip().parents[0] // TODO: (Stas) This is wrong. Modified only to satisfy compilation.
for bit := uint32(0); bit < vbNumBits; bit++ {
checker := bitConditionChecker{bit: bit, chain: b}
cache := &b.warningCaches[bit]

View File

@ -161,7 +161,7 @@ func readBlockTree(v1BlockIdxBucket database.Bucket) (map[daghash.Hash]*blockCha
}
blockHash := header.BlockHash()
prevHash := header.PrevBlock
prevHash := header.PrevBlocks[0] // TODO: (Stas) This is wrong. Modified only to satisfy compilation.
if blocksMap[blockHash] == nil {
blocksMap[blockHash] = &blockChainContext{height: -1}

View File

@ -434,7 +434,7 @@ func (view *UtxoViewpoint) disconnectTransactions(db database.DB, block *btcutil
// Update the best hash for view to the previous block since all of the
// transactions for the current block have been disconnected.
view.SetBestHash(&block.MsgBlock().Header.PrevBlock)
view.SetBestHash(&block.MsgBlock().Header.PrevBlocks[0]) // TODO: (Stas) This is wrong. Modified only to satisfy compilation.
return nil
}

View File

@ -973,7 +973,7 @@ func (b *BlockChain) checkConnectBlock(node *blockNode, block *btcutil.Block, vi
}
// Ensure the view is for the node being checked.
parentHash := &block.MsgBlock().Header.PrevBlock
parentHash := &block.MsgBlock().Header.PrevBlocks[0]
if !view.BestHash().IsEqual(parentHash) {
return AssertError(fmt.Sprintf("inconsistent view when "+
"checking block connection: best hash is %v instead "+
@ -1141,7 +1141,7 @@ func (b *BlockChain) checkConnectBlock(node *blockNode, block *btcutil.Block, vi
// Enforce CHECKSEQUENCEVERIFY during all block validation checks once
// the soft-fork deployment is fully active.
csvState, err := b.deploymentState(node.parent, dagconfig.DeploymentCSV)
csvState, err := b.deploymentState(&node.parents[0], dagconfig.DeploymentCSV) // TODO: (Stas) This is wrong. Modified only to satisfy compilation.
if err != nil {
return err
}
@ -1153,7 +1153,7 @@ func (b *BlockChain) checkConnectBlock(node *blockNode, block *btcutil.Block, vi
// We obtain the MTP of the *previous* block in order to
// determine if transactions in the current block are final.
medianTime := node.parent.CalcPastMedianTime()
medianTime := node.parents[0].CalcPastMedianTime() // TODO: (Stas) This is wrong. Modified only to satisfy compilation.
// Additionally, if the CSV soft-fork package is now active,
// then we also enforce the relative sequence number based
@ -1212,9 +1212,9 @@ func (b *BlockChain) CheckConnectBlockTemplate(block *btcutil.Block) error {
// current chain.
tip := b.bestChain.Tip()
header := block.MsgBlock().Header
if tip.hash != header.PrevBlock {
if tip.hash != header.PrevBlocks[0] { // TODO: (Stas) This is wrong. Modified only to satisfy compilation.
str := fmt.Sprintf("previous block must be the current chain tip %v, "+
"instead got %v", tip.hash, header.PrevBlock)
"instead got %v", tip.hash, header.PrevBlocks[0]) // TODO: (Stas) This is wrong. Modified only to satisfy compilation.
return ruleError(ErrPrevBlockNotBest, str)
}
@ -1232,6 +1232,6 @@ func (b *BlockChain) CheckConnectBlockTemplate(block *btcutil.Block) error {
// is not needed and thus extra work can be avoided.
view := NewUtxoViewpoint()
view.SetBestHash(&tip.hash)
newNode := newBlockNode(&header, tip)
newNode := newBlockNode(&header, []blockNode{*tip}) // TODO: (Stas) This is wrong. Modified only to satisfy compilation.
return b.checkConnectBlock(newNode, block, view, nil)
}

View File

@ -238,22 +238,30 @@ func TestCheckSerializedHeight(t *testing.T) {
// test Block operations.
var Block100000 = wire.MsgBlock{
Header: wire.BlockHeader{
Version: 1,
PrevBlock: daghash.Hash([32]byte{ // Make go vet happy.
0x50, 0x12, 0x01, 0x19, 0x17, 0x2a, 0x61, 0x04,
0x21, 0xa6, 0xc3, 0x01, 0x1d, 0xd3, 0x30, 0xd9,
0xdf, 0x07, 0xb6, 0x36, 0x16, 0xc2, 0xcc, 0x1f,
0x1c, 0xd0, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00,
}), // 000000000002d01c1fccc21636b607dfd930d31d01c3a62104612a1719011250
Version: 1,
NumPrevBlocks: 2,
PrevBlocks: []daghash.Hash{
[32]byte{ // Make go vet happy.
0x82, 0xdc, 0xbd, 0xe6, 0x88, 0x37, 0x74, 0x5b,
0x78, 0x6b, 0x03, 0x1d, 0xa3, 0x48, 0x3c, 0x45,
0x3f, 0xc3, 0x2e, 0xd4, 0x53, 0x5b, 0x6f, 0x26,
0x26, 0xb0, 0x48, 0x4f, 0x09, 0x00, 0x00, 0x00,
}, // MainNet genesis
[32]byte{ // Make go vet happy.
0xc1, 0x5b, 0x71, 0xfe, 0x20, 0x70, 0x0f, 0xd0,
0x08, 0x49, 0x88, 0x1b, 0x32, 0xb5, 0xbd, 0x13,
0x17, 0xbe, 0x75, 0xe7, 0x29, 0x46, 0xdd, 0x03,
0x01, 0x92, 0x90, 0xf1, 0xca, 0x8a, 0x88, 0x11,
}}, // SimNet genesis
MerkleRoot: daghash.Hash([32]byte{ // Make go vet happy.
0x66, 0x57, 0xa9, 0x25, 0x2a, 0xac, 0xd5, 0xc0,
0xb2, 0x94, 0x09, 0x96, 0xec, 0xff, 0x95, 0x22,
0x28, 0xc3, 0x06, 0x7c, 0xc3, 0x8d, 0x48, 0x85,
0xef, 0xb5, 0xa4, 0xac, 0x42, 0x47, 0xe9, 0xf3,
}), // f3e94742aca4b5ef85488dc37c06c3282295ffec960994b2c0d5ac2a25a95766
Timestamp: time.Unix(1293623863, 0), // 2010-12-29 11:57:43 +0000 UTC
Bits: 0x1b04864c, // 453281356
Nonce: 0x10572b0f, // 274148111
Timestamp: time.Unix(1529483563, 0), // 2018-06-20 08:32:43 +0000 UTC
Bits: 0x1e00ffff, // 503382015
Nonce: 0x000ae53f, // 714047
},
Transactions: []*wire.MsgTx{
{

View File

@ -113,7 +113,7 @@ func (c bitConditionChecker) Condition(node *blockNode) (bool, error) {
return false, nil
}
expectedVersion, err := c.chain.calcNextBlockVersion(node.parent)
expectedVersion, err := c.chain.calcNextBlockVersion(&node.parents[0]) // TODO: (Stas) This is wrong. Modified only to satisfy compilation.
if err != nil {
return false, err
}
@ -241,7 +241,7 @@ func (b *BlockChain) warnUnknownRuleActivations(node *blockNode) error {
for bit := uint32(0); bit < vbNumBits; bit++ {
checker := bitConditionChecker{bit: bit, chain: b}
cache := &b.warningCaches[bit]
state, err := b.thresholdState(node.parent, checker, cache)
state, err := b.thresholdState(&node.parents[0], checker, cache) // TODO: (Stas) This is wrong. Modified only to satisfy compilation.
if err != nil {
return err
}
@ -278,7 +278,7 @@ func (b *BlockChain) warnUnknownVersions(node *blockNode) error {
// Warn if enough previous blocks have unexpected versions.
numUpgraded := uint32(0)
for i := uint32(0); i < unknownVerNumToCheck && node != nil; i++ {
expectedVersion, err := b.calcNextBlockVersion(node.parent)
expectedVersion, err := b.calcNextBlockVersion(&node.parents[0]) // TODO: (Stas) This is wrong. Modified only to satisfy compilation.
if err != nil {
return err
}
@ -288,7 +288,7 @@ func (b *BlockChain) warnUnknownVersions(node *blockNode) error {
numUpgraded++
}
node = node.parent
node = &node.parents[0] // TODO: (Stas) This is wrong. Modified only to satisfy compilation.
}
if numUpgraded > unknownVerWarnNum {
log.Warn("Unknown block versions are being mined, so new " +