Skip to content

Commit

Permalink
Fix adding ourselves to dht.getProviders
Browse files Browse the repository at this point in the history
  • Loading branch information
ianopolous committed Jul 11, 2023
1 parent e457e3d commit 0a7e302
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/main/java/org/peergos/protocol/dht/KademliaEngine.java
Original file line number Diff line number Diff line change
Expand Up @@ -109,12 +109,14 @@ public void receiveRequest(Dht.Message msg, PeerId source, Stream stream) {
case GET_PROVIDERS: {
Multihash hash = Multihash.deserialize(msg.getKey().toByteArray());
Set<PeerAddresses> providers = providersStore.getProviders(hash);
if (blocks.hasAny(hash).join())
if (blocks.hasAny(hash).join()) {
providers = new HashSet<>(providers);
providers.add(new PeerAddresses(ourPeerId, addressBook.getAddrs(PeerId.fromBase58(ourPeerId.toBase58()))
.join()
.stream()
.map(a -> new MultiAddress(a.toString()))
.collect(Collectors.toList())));
}
Dht.Message.Builder builder = msg.toBuilder();
builder = builder.addAllProviderPeers(providers.stream()
.map(PeerAddresses::toProtobuf)
Expand Down

0 comments on commit 0a7e302

Please sign in to comment.