OSDN Git Service

Merge branch 'master' into dev-blockindex
authoroys <oys@oysdeMBP.localdomain>
Tue, 25 Jun 2019 10:42:08 +0000 (18:42 +0800)
committeroys <oys@oysdeMBP.localdomain>
Tue, 25 Jun 2019 10:42:08 +0000 (18:42 +0800)
1  2 
protocol/protocol.go

@@@ -105,15 -109,17 +105,19 @@@ func (c *Chain) BestBlockHeight() uint6
  func (c *Chain) BestBlockHash() *bc.Hash {
        c.cond.L.Lock()
        defer c.cond.L.Unlock()
 -      return &c.bestNode.Hash
 +      bestHash := c.bestBlockHeader.Hash()
 +      return &bestHash
  }
  
- // BestBlockHeader returns the chain tail block
+ // BestIrreversibleHeader returns the chain best irreversible block
+ func (c *Chain) BestIrreversibleHeader() *types.BlockHeader {
+       return c.bestIrreversibleNode.BlockHeader()
+ }
  func (c *Chain) BestBlockHeader() *types.BlockHeader {
 -      node := c.index.BestNode()
 -      return node.BlockHeader()
 +      c.cond.L.Lock()
 +      defer c.cond.L.Unlock()
 +      return c.bestBlockHeader
  }
  
  // InMainChain checks wheather a block is in the main chain