aboutsummaryrefslogtreecommitdiff
path: root/trillian.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 /trillian.go
parentdef4ef7b3b47d955a9a4932549536f36aa6b4745 (diff)
fixed redundant tree head checking
Diffstat (limited to 'trillian.go')
-rw-r--r--trillian.go9
1 files changed, 4 insertions, 5 deletions
diff --git a/trillian.go b/trillian.go
index 02b220c..8ae96a1 100644
--- a/trillian.go
+++ b/trillian.go
@@ -62,16 +62,15 @@ func checkGetConsistencyProof(lp *LogParameters, rsp *trillian.GetConsistencyPro
return checkHashPath(lp.HashType.Size(), rsp.Proof.Hashes)
}
-func checkGetLatestSignedLogRoot(lp *LogParameters, rsp *trillian.GetLatestSignedLogRootResponse, err error) (int, error) {
+func checkGetLatestSignedLogRoot(lp *LogParameters, rsp *trillian.GetLatestSignedLogRootResponse, err error, out *types.LogRootV1) (int, error) {
if err != nil || rsp == nil || rsp.SignedLogRoot == nil || rsp.SignedLogRoot.LogRoot == nil {
return http.StatusInternalServerError, fmt.Errorf("%v", err)
}
- var lr types.LogRootV1
- if err := lr.UnmarshalBinary(rsp.SignedLogRoot.LogRoot); err != nil {
+ if err := out.UnmarshalBinary(rsp.SignedLogRoot.LogRoot); err != nil {
return http.StatusInternalServerError, fmt.Errorf("cannot unmarshal log root: %v", err)
}
- if len(lr.RootHash) != lp.HashType.Size() {
- return http.StatusInternalServerError, fmt.Errorf("invalid root hash: %v", lr.RootHash)
+ if len(out.RootHash) != lp.HashType.Size() {
+ return http.StatusInternalServerError, fmt.Errorf("invalid root hash: %v", out.RootHash)
}
return 0, nil
}