OSDN Git Service

Fix chain's height is 0
authorgguoss <1536310027@qq.com>
Fri, 3 Nov 2017 07:01:02 +0000 (15:01 +0800)
committergguoss <1536310027@qq.com>
Fri, 3 Nov 2017 07:01:02 +0000 (15:01 +0800)
protocol/protocol.go

index 9297018..ac838fd 100644 (file)
@@ -168,6 +168,9 @@ func NewChain(initialBlockHash bc.Hash, store Store, txPool *TxPool) (*Chain, er
 func (c *Chain) Height() uint64 {
        c.state.cond.L.Lock()
        defer c.state.cond.L.Unlock()
+       if c.state.block == nil {
+               return 0
+       }
        return c.state.block.Height
 }