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