X-Git-Url: http://git.osdn.net/view?p=bytom%2Fvapor.git;a=blobdiff_plain;f=toolbar%2Fapi_node%2Fblock.go;h=d8a1bbf0f472ef8a1a33b30c27eb27e4ab289572;hp=a9789a28017768b34871980d31f3863e392d08de;hb=faa1881b5d4ad5e6f8409b6c4aaecf6aa7f8a946;hpb=3df751629b0461637eef6d863f5f679c908c7eb4 diff --git a/toolbar/api_node/block.go b/toolbar/api_node/block.go index a9789a28..d8a1bbf0 100644 --- a/toolbar/api_node/block.go +++ b/toolbar/api_node/block.go @@ -27,7 +27,29 @@ func (n *Node) getRawBlock(req *getRawBlockReq) (*types.Block, error) { if err != nil { return nil, errors.Wrap(err, "json marshal") } - resp := &api.GetRawBlockResp{} return resp.RawBlock, n.request(url, payload, resp) } + +func (n *Node) GetVoteByHash(hash string) ([]api.VoteInfo, error) { + return n.getVoteResult(&getVoteResultReq{BlockHash: hash}) +} + +func (n *Node) GetVoteByHeight(height uint64) ([]api.VoteInfo, error) { + return n.getVoteResult(&getVoteResultReq{BlockHeight: height}) +} + +type getVoteResultReq struct { + BlockHeight uint64 `json:"block_height"` + BlockHash string `json:"block_hash"` +} + +func (n *Node) getVoteResult(req *getVoteResultReq) ([]api.VoteInfo, error) { + url := "/get-vote-result" + payload, err := json.Marshal(req) + if err != nil { + return nil, errors.Wrap(err, "json marshal") + } + resp := []api.VoteInfo{} + return resp, n.request(url, payload, &resp) +}