OSDN Git Service

Edit api (#1544)
authorPaladz <yzhu101@uottawa.ca>
Thu, 3 Jan 2019 09:19:17 +0000 (17:19 +0800)
committerGitHub <noreply@github.com>
Thu, 3 Jan 2019 09:19:17 +0000 (17:19 +0800)
* p2p/discv5: fix idx can be negative after uint convert to int(can cause crash) (#1307)

* fix bug for concurrent map access

* get raw block return the tx status

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)
 }