From f02d9ad52b4b70fc1af8224201cf993faa82eaee Mon Sep 17 00:00:00 2001 From: Rasmus Dahlberg Date: Tue, 17 Nov 2020 12:11:30 +0100 Subject: fixed redundant tree head checking --- trillian.go | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'trillian.go') 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 } -- cgit v1.2.3