From 2bf2b2d765c5003307544885b9321b32cc09d8bb Mon Sep 17 00:00:00 2001 From: Michael Muré Date: Mon, 9 Nov 2020 00:34:48 +0100 Subject: entity: unique function to generate IDs --- bug/operation.go | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) (limited to 'bug/operation.go') diff --git a/bug/operation.go b/bug/operation.go index 107c954e..bdaa2016 100644 --- a/bug/operation.go +++ b/bug/operation.go @@ -1,7 +1,6 @@ package bug import ( - "crypto/sha256" "encoding/json" "fmt" "time" @@ -55,11 +54,6 @@ type Operation interface { IsOperation() } -func deriveId(data []byte) entity.Id { - sum := sha256.Sum256(data) - return entity.Id(fmt.Sprintf("%x", sum)) -} - func idOperation(op Operation) entity.Id { base := op.base() @@ -78,7 +72,7 @@ func idOperation(op Operation) entity.Id { panic(err) } - base.id = deriveId(data) + base.id = entity.DeriveId(data) } return base.id } @@ -109,7 +103,7 @@ func newOpBase(opType OperationType, author identity.Interface, unixTime int64) func (op *OpBase) UnmarshalJSON(data []byte) error { // Compute the Id when loading the op from disk. - op.id = deriveId(data) + op.id = entity.DeriveId(data) aux := struct { OperationType OperationType `json:"type"` -- cgit