From 869d2e038665a102ca1162b9ccc41e7601438d36 Mon Sep 17 00:00:00 2001 From: Christian Basler Date: Fri, 19 May 2017 19:49:35 +0200 Subject: [PATCH] Fixed pubkey retrieval Broadcast subscriptions shouldn't be disabled every time a pubkey, message or broadcast comes along... (this might also fix other strange behaviour) --- .../java/ch/dissem/bitmessage/DefaultMessageListener.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/core/src/main/java/ch/dissem/bitmessage/DefaultMessageListener.java b/core/src/main/java/ch/dissem/bitmessage/DefaultMessageListener.java index bdb61b6..4fb438f 100644 --- a/core/src/main/java/ch/dissem/bitmessage/DefaultMessageListener.java +++ b/core/src/main/java/ch/dissem/bitmessage/DefaultMessageListener.java @@ -104,7 +104,7 @@ class DefaultMessageListener implements NetworkHandler.MessageListener, Internal } else { address = ctx.getAddressRepository().findContact(pubkey.getRipe()); } - if (address != null) { + if (address != null && address.getPubkey() == null) { updatePubkey(address, pubkey); } } catch (DecryptionFailedException ignore) { @@ -170,11 +170,15 @@ class DefaultMessageListener implements NetworkHandler.MessageListener, Internal } protected void receive(InventoryVector iv, Plaintext msg) { + BitmessageAddress contact = ctx.getAddressRepository().getAddress(msg.getFrom().getAddress()); + if (contact != null && contact.getPubkey() == null) { + updatePubkey(contact, msg.getFrom().getPubkey()); + } + msg.setInventoryVector(iv); labeler.setLabels(msg); ctx.getMessageRepository().save(msg); listener.receive(msg); - updatePubkey(msg.getFrom(), msg.getFrom().getPubkey()); if (msg.getType() == Plaintext.Type.MSG && msg.getTo().has(Pubkey.Feature.DOES_ACK)) { ObjectMessage ack = msg.getAckMessage();