OSDN Git Service

fix bug (#331)
authorwz <mars@bytom.io>
Fri, 19 Jul 2019 10:11:36 +0000 (18:11 +0800)
committerPaladz <yzhu101@uottawa.ca>
Fri, 19 Jul 2019 10:11:35 +0000 (18:11 +0800)
api/block_retrieve.go

index 56fdbdc..10b9fb0 100644 (file)
@@ -72,10 +72,11 @@ func (a *API) getBlock(ins BlockReq) Response {
        for i, w := range block.Witness {
                witness[i] = w
        }
-
-       blocker, err := a.chain.GetBlocker(&block.PreviousBlockHash, block.Timestamp)
-       if err != nil {
-               return NewErrorResponse(err)
+       var blocker string
+       if block.Height > 0 {
+               if blocker, err = a.chain.GetBlocker(&block.PreviousBlockHash, block.Timestamp); err != nil {
+                       return NewErrorResponse(err)
+               }
        }
 
        resp := &GetBlockResp{