import (
"encoding/json"
+ "github.com/vapor/api"
"github.com/vapor/errors"
- "github.com/vapor/protocol/bc"
"github.com/vapor/toolbar/common"
)
return &Node{hostPort: hostPort}
}
-func (n *Node) GetBlockByHash(hash string) (string, *bc.TransactionStatus, error) {
+func (n *Node) GetBlockByHash(hash string) (*api.GetRawBlockResp, error) {
return n.getRawBlock(&getRawBlockReq{BlockHash: hash})
}
-func (n *Node) GetBlockByHeight(height uint64) (string, *bc.TransactionStatus, error) {
+func (n *Node) GetBlockByHeight(height uint64) (*api.GetRawBlockResp, error) {
return n.getRawBlock(&getRawBlockReq{BlockHeight: height})
}
BlockHash string `json:"block_hash"`
}
-type getRawBlockResp struct {
- RawBlock string `json:"raw_block"`
- // TransactionStatus has same marshalling rule for both bytom and vapor
- TransactionStatus *bc.TransactionStatus `json:"transaction_status"`
-}
-
-func (n *Node) getRawBlock(req *getRawBlockReq) (string, *bc.TransactionStatus, error) {
+func (n *Node) getRawBlock(req *getRawBlockReq) (*api.GetRawBlockResp, error) {
url := "/get-raw-block"
payload, err := json.Marshal(req)
if err != nil {
- return "", nil, errors.Wrap(err, "json marshal")
+ return nil, errors.Wrap(err, "json marshal")
}
- res := &getRawBlockResp{}
- return res.RawBlock, res.TransactionStatus, n.request(url, payload, res)
+ resp := &api.GetRawBlockResp{}
+ return resp, n.request(url, payload, resp)
}
type response struct {