From d237c601bdd05b7a58a82d8f4dcdd9140b868d83 Mon Sep 17 00:00:00 2001
From: vtexier <vit@free.fr>
Date: Fri, 21 Feb 2020 17:57:18 +0100
Subject: [PATCH] [fix] fix certify identity duplicates in combobox and
database
---
src/sakia/data/repositories/identities.py | 14 +++++++++++++-
1 file changed, 13 insertions(+), 1 deletion(-)
diff --git a/src/sakia/data/repositories/identities.py b/src/sakia/data/repositories/identities.py
index c49f6ccf..aa192f4b 100644
--- a/src/sakia/data/repositories/identities.py
+++ b/src/sakia/data/repositories/identities.py
@@ -23,6 +23,18 @@ class IdentitiesRepo:
Commit an identity to the database
:param sakia.data.entities.Identity identity: the identity to commit
"""
+ if identity.blockstamp != BlockUID.empty():
+ # Search same identity with empty blockstamp (incomplete)
+ same_with_empty_blockstamp = self.get_one(
+ currency=identity.currency,
+ uid=identity.uid,
+ pubkey=identity.pubkey,
+ blockstamp=BlockUID.empty()
+ )
+ # if same identity with empty blockstamp...
+ if same_with_empty_blockstamp:
+ # remove it to avoid duplicates
+ self.drop(same_with_empty_blockstamp)
identity_tuple = attr.astuple(identity)
values = ",".join(["?"] * len(identity_tuple))
self._conn.execute(
@@ -64,7 +76,7 @@ class IdentitiesRepo:
def get_one(self, **search):
"""
Get an existing identity in the database
- :param dict search: the criterions of the lookup
+ :param **kwargs search: the criterions of the lookup
:rtype: sakia.data.entities.Identity
"""
filters = []
--
GitLab