From 694eb276a650d6fbd9566dc4d978f9997f4f4577 Mon Sep 17 00:00:00 2001 From: Andrew Ayer Date: Wed, 21 May 2025 14:33:58 -0400 Subject: [PATCH] Also check timestamp when comparing STHs otherwise we might fail to delete unverified_sths if they have a different timestamp --- cttypes/sth.go | 4 ++++ monitor/monitor.go | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) 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 {