diff --git a/src/sakia/data/repositories/identities.py b/src/sakia/data/repositories/identities.py index c49f6ccf6802b7cd16c723eb35d2c5f6368899f6..aa192f4b7119f456504c53ae1df5a825efb3d28d 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 = []