aboutsummaryrefslogtreecommitdiff
path: root/handler.go
diff options
context:
space:
mode:
authorRasmus Dahlberg <rasmus.dahlberg@kau.se>2020-10-28 14:56:11 +0100
committerRasmus Dahlberg <rasmus.dahlberg@kau.se>2020-10-28 14:56:11 +0100
commitcaca215c9516e8dc236a8510a6a5467c267d2331 (patch)
treeb4d0ee37f09e525e9402c5d2bdcbed72ef0cd483 /handler.go
parentd752d967335e1418f27e03e0389b01178b28f232 (diff)
added consistency-proof code path
Diffstat (limited to 'handler.go')
-rw-r--r--handler.go24
1 files changed, 24 insertions, 0 deletions
diff --git a/handler.go b/handler.go
index ee1eae6..119f65c 100644
--- a/handler.go
+++ b/handler.go
@@ -174,6 +174,30 @@ func getProofByHash(ctx context.Context, i *Instance, w http.ResponseWriter, r *
// getConsistencyProof provides a consistency proof between two STHs
func getConsistencyProof(ctx context.Context, i *Instance, w http.ResponseWriter, r *http.Request) (int, error) {
glog.Info("in getConsistencyProof")
+ request, err := NewGetConsistencyProofRequest(r)
+ if err != nil {
+ return http.StatusBadRequest, err
+ } // request can be decoded and is valid
+
+ trillianRequest := trillian.GetConsistencyProofRequest{
+ LogId: i.LogParameters.TreeId,
+ FirstTreeSize: int64(request.First),
+ SecondTreeSize: int64(request.Second),
+ }
+ trillianResponse, err := i.Client.GetConsistencyProof(ctx, &trillianRequest)
+ if err != nil {
+ return http.StatusInternalServerError, fmt.Errorf("failed fetching consistency proof from Trillian backend: %v", err)
+ }
+ // TODO: santity-checks?
+
+ response, err := NewGetConsistencyProofResponse(i.LogParameters.LogId, request.First, request.Second, trillianResponse.Proof)
+ if err != nil {
+ return http.StatusInternalServerError, fmt.Errorf("failed creating get-consistency-proof response: %v", err)
+ }
+ if err := WriteJsonResponse(response, w); err != nil {
+ return http.StatusInternalServerError, err
+ }
+ return http.StatusOK, nil
return http.StatusOK, nil // TODO
}