[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>
This commit is contained in:
HuKeping 2016-03-11 09:51:40 +08:00
parent 2f61b0a445
commit 6cd6b4726c
1 changed files with 1 additions and 5 deletions

View File

@ -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