aboutsummaryrefslogtreecommitdiff
path: root/client/client.go
diff options
context:
space:
mode:
authorRasmus Dahlberg <rasmus.dahlberg@kau.se>2020-11-05 18:17:23 +0100
committerRasmus Dahlberg <rasmus.dahlberg@kau.se>2020-11-05 18:17:23 +0100
commit5ba3cec231989ba1deb5926f8fdcd8caec169821 (patch)
tree6f86d8b9d7defea543ab87de67c9f406433365e4 /client/client.go
parentf806c09af385c6bafded7ff9c7290e10a4d666b9 (diff)
added client-side get-entries
Diffstat (limited to 'client/client.go')
-rw-r--r--client/client.go20
1 files changed, 18 insertions, 2 deletions
diff --git a/client/client.go b/client/client.go
index 5f24fdc..43386b0 100644
--- a/client/client.go
+++ b/client/client.go
@@ -193,8 +193,24 @@ func (c *Client) GetProofByHash(ctx context.Context, treeSize uint64, rootHash,
return item, nil
}
-func (c *Client) GetEntries(ctx context.Context, start, end uint64) (*stfe.StItem, error) {
- return nil, fmt.Errorf("TODO: Client.GetEntries()")
+func (c *Client) GetEntries(ctx context.Context, start, end uint64) ([]*stfe.GetEntryResponse, error) {
+ req, err := http.NewRequest("GET", c.protocol()+c.Log.BaseUrl+"/get-entries", nil)
+ if err != nil {
+ return nil, fmt.Errorf("failed creating http request: %v", err)
+ }
+ req.Header.Set("Content-Type", "application/json")
+ q := req.URL.Query()
+ q.Add("start", fmt.Sprintf("%d", start))
+ q.Add("end", fmt.Sprintf("%d", end))
+ req.URL.RawQuery = q.Encode()
+ glog.V(2).Infof("created http request: %s %s", req.Method, req.URL)
+
+ var rsp []*stfe.GetEntryResponse
+ if err := c.doRequest(ctx, req, &rsp); err != nil {
+ return nil, err
+ }
+ // TODO: verify signature over leaf data
+ return rsp, nil
}
// GetAnchors fetches the log's trust anchors. Safe to use without a client