From 6cd6b4726cc616b85c107dccbb31443a010b12fb Mon Sep 17 00:00:00 2001
From: HuKeping <hukeping@huawei.com>
Date: Fri, 11 Mar 2016 09:51:40 +0800
Subject: [PATCH] [MISC 1/4] Tiny refactor

Reduce function "snapshotExpired" in a simpler form and replace the
literal string by the constants defined in the data package.

Signed-off-by: Hu Keping <hukeping@huawei.com>
---
 server/timestamp/timestamp.go | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/server/timestamp/timestamp.go b/server/timestamp/timestamp.go
index 4116f8ab7e..2cf3628f5c 100644
--- a/server/timestamp/timestamp.go
+++ b/server/timestamp/timestamp.go
@@ -97,11 +97,7 @@ func timestampExpired(ts *data.SignedTimestamp) bool {
 func snapshotExpired(ts *data.SignedTimestamp, snapshot []byte) bool {
 	// If this check failed, it means the current snapshot was not exactly what we expect
 	// via the timestamp. So we can consider it to be "expired."
-	if err := data.CheckHashes(snapshot, ts.Signed.Meta["snapshot"].Hashes); err != nil {
-		return true
-	}
-
-	return false
+	return data.CheckHashes(snapshot, ts.Signed.Meta[data.CanonicalSnapshotRole].Hashes) != nil
 }
 
 // CreateTimestamp creates a new timestamp. If a prev timestamp is provided, it