From 283e97111b0b39a4e8f7717234f0bfbbb4f481af Mon Sep 17 00:00:00 2001 From: Michael Muré Date: Tue, 27 Aug 2019 12:11:51 +0200 Subject: bug: make sure there is no Operation's hash collision --- bug/bug.go | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'bug/bug.go') diff --git a/bug/bug.go b/bug/bug.go index ca817dc1..ae662ef1 100644 --- a/bug/bug.go +++ b/bug/bug.go @@ -330,12 +330,18 @@ func (bug *Bug) Validate() error { } // Check that there is no more CreateOp op + // Check that there is no colliding operation's ID it := NewOperationIterator(bug) createCount := 0 + ids := make(map[entity.Id]struct{}) for it.Next() { if it.Value().base().OperationType == CreateOp { createCount++ } + if _, ok := ids[it.Value().Id()]; ok { + return fmt.Errorf("id collision: %s", it.Value().Id()) + } + ids[it.Value().Id()] = struct{}{} } if createCount != 1 { -- cgit