aboutsummaryrefslogtreecommitdiff
path: root/handler.go
diff options
context:
space:
mode:
authorRasmus Dahlberg <rasmus.dahlberg@kau.se>2020-11-17 12:11:30 +0100
committerRasmus Dahlberg <rasmus.dahlberg@kau.se>2020-11-17 12:11:30 +0100
commitf02d9ad52b4b70fc1af8224201cf993faa82eaee (patch)
tree811472fac4b5616f845d64536d5b12169d511f62 /handler.go
parentdef4ef7b3b47d955a9a4932549536f36aa6b4745 (diff)
fixed redundant tree head checking
Diffstat (limited to 'handler.go')
-rw-r--r--handler.go10
1 files changed, 4 insertions, 6 deletions
diff --git a/handler.go b/handler.go
index fe93f4f..d77379d 100644
--- a/handler.go
+++ b/handler.go
@@ -9,6 +9,7 @@ import (
"github.com/golang/glog"
"github.com/google/trillian"
+ "github.com/google/trillian/types"
)
// handler implements the http.Handler interface, and contains a reference
@@ -180,15 +181,12 @@ func getSth(ctx context.Context, i *Instance, w http.ResponseWriter, _ *http.Req
trsp, err := i.Client.GetLatestSignedLogRoot(ctx, &trillian.GetLatestSignedLogRootRequest{
LogId: i.LogParameters.TreeId,
})
- if status, errInner := checkGetLatestSignedLogRoot(i.LogParameters, trsp, err); errInner != nil {
+ var lr types.LogRootV1
+ if status, errInner := checkGetLatestSignedLogRoot(i.LogParameters, trsp, err, &lr); errInner != nil {
return status, fmt.Errorf("bad GetLatestSignedLogRootResponse: %v", errInner)
}
- th, err := NewTreeHeadV1(i.LogParameters, trsp.SignedLogRoot)
- if err != nil {
- return http.StatusInternalServerError, fmt.Errorf("failed creating tree head: %v", err)
- }
- sth, err := i.LogParameters.genV1Sth(th)
+ sth, err := i.LogParameters.genV1Sth(NewTreeHeadV1(i.LogParameters, &lr))
if err != nil {
return http.StatusInternalServerError, fmt.Errorf("failed creating signed tree head: %v", err)
}