diff --git a/cttypes/sth.go b/cttypes/sth.go index 880e7da..aec9d2a 100644 --- a/cttypes/sth.go +++ b/cttypes/sth.go @@ -31,3 +31,7 @@ type GossipedSignedTreeHead struct { func (sth *SignedTreeHead) TimestampTime() time.Time { return time.UnixMilli(int64(sth.Timestamp)) } + +func (sth *SignedTreeHead) Same(other *SignedTreeHead) bool { + return sth.TreeSize == other.TreeSize && sth.Timestamp == other.Timestamp && sth.RootHash == other.RootHash +} diff --git a/monitor/monitor.go b/monitor/monitor.go index 1e41eaa..14cad2e 100644 --- a/monitor/monitor.go +++ b/monitor/monitor.go @@ -357,7 +357,7 @@ func newBatch(number uint64, begin uint64, sths []*StoredSTH, downloadJobSize ui func appendSTH(sths []*StoredSTH, sth *StoredSTH) []*StoredSTH { i := len(sths) for i > 0 { - if sths[i-1].TreeSize == sth.TreeSize && sths[i-1].RootHash == sth.RootHash { + if sths[i-1].Same(&sth.SignedTreeHead) { return sths } if sths[i-1].TreeSize < sth.TreeSize {