From eba6b368bf736f9675c4a576390fb659bf733ada Mon Sep 17 00:00:00 2001 From: Xavier Perret <xa.perret@outlook.com> Date: Sun, 30 Oct 2022 19:00:08 +0100 Subject: [PATCH] added method to get transaction from db by id --- app/object-storage/object-storage.go | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/app/object-storage/object-storage.go b/app/object-storage/object-storage.go index af30bd0..5236f10 100644 --- a/app/object-storage/object-storage.go +++ b/app/object-storage/object-storage.go @@ -285,12 +285,21 @@ func TestObjectStorage() { } } -func IsTransactionInDatabase(objectStorage Blob, trans Transaction) bool { +func GetTransactionInDatabaseById(objectStorage Blob, trans Transaction) Transaction { db := ReadDatabaseFromBlobStorage(objectStorage) for _, t := range db { if t.Id == trans.Id { - return true + return trans } } - return false + return Transaction{ + Id: "", + Sender: "", + Receiver: "", + Amount: "", + } +} + +func IsTransactionInDatabase(objectStorage Blob, trans Transaction) bool { + return GetTransactionInDatabaseById(objectStorage, trans).Id == trans.Id } -- GitLab