OSDN Git Service

get raw block return the tx status (#1546)
authorPaladz <yzhu101@uottawa.ca>
Thu, 3 Jan 2019 09:18:58 +0000 (17:18 +0800)
committerGitHub <noreply@github.com>
Thu, 3 Jan 2019 09:18:58 +0000 (17:18 +0800)
api/block_retrieve.go

index b49f76b..f4543a1 100644 (file)
@@ -124,7 +124,8 @@ func (a *API) getBlock(ins BlockReq) Response {
 
 // GetRawBlockResp is resp struct for getRawBlock API
 type GetRawBlockResp struct {
-       RawBlock *types.Block `json:"raw_block"`
+       RawBlock          *types.Block          `json:"raw_block"`
+       TransactionStatus *bc.TransactionStatus `json:"transaction_status"`
 }
 
 func (a *API) getRawBlock(ins BlockReq) Response {
@@ -133,7 +134,16 @@ func (a *API) getRawBlock(ins BlockReq) Response {
                return NewErrorResponse(err)
        }
 
-       resp := GetRawBlockResp{RawBlock: block}
+       blockHash := block.Hash()
+       txStatus, err := a.chain.GetTransactionStatus(&blockHash)
+       if err != nil {
+               return NewErrorResponse(err)
+       }
+
+       resp := GetRawBlockResp{
+               RawBlock:          block,
+               TransactionStatus: txStatus,
+       }
        return NewSuccessResponse(resp)
 }