Skip to content

Don't filter out local node ID when returning peer list (continued) #975

Merged
kaykurokawa merged 6 commits intomasterfrom
ordex-dht-list-fix
Nov 7, 2017
Merged

Don't filter out local node ID when returning peer list (continued) #975
kaykurokawa merged 6 commits intomasterfrom
ordex-dht-list-fix

Conversation

@kaykurokawa
Copy link
Copy Markdown
Contributor

Continuing from #968

Removed the "if" statement in dht.node.getPeersForBlob(), where it did some strange workaround for filtering localhosts from the results.

I added argument "filter_self" to DHTPeerFinder.find_peers_for_blob() where it will filter itself from peer results if True, this option is needed when downloading blobs since you don't want to download blobs from yourself. In other use cases, such as API command peer_list, filter_self is defaulted to False so you will be able to find yourself. Before #968, the filtering of itself was done in the DHT code and would actually affect availability. Now it is done purely outside of the DHT code so it has no impact on availability.

In order for DHTPeerFinder to know whether a peer was itself or not, I needed to add the "peerPort" as member variable that is initialized by the dht.node class. Thus when announcing blobs using dht.node.announceHaveBlob(), port is no longer needed as an argument. I think this is a more logical way of doing it since externalIP is already a member variable of the dht.node class and there is no use case where we need to announce blobs on different ports.

@kaykurokawa kaykurokawa changed the title Don't filter out local node ID when returning peer list (continued) [WIP] Don't filter out local node ID when returning peer list (continued) Oct 30, 2017
@kaykurokawa kaykurokawa force-pushed the ordex-dht-list-fix branch 2 times, most recently from 3ca71ab to 182eed0 Compare October 30, 2017 18:08
@kaykurokawa kaykurokawa changed the title [WIP] Don't filter out local node ID when returning peer list (continued) Don't filter out local node ID when returning peer list (continued) Oct 30, 2017
if self.node_id != peer[6:]:
host = ".".join([str(ord(d)) for d in peer[:4]])
if host == "127.0.0.1" and "from_peer" in result \
and result["from_peer"] != "self":
Copy link
Copy Markdown
Member

@jackrobison jackrobison Oct 31, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is coming from https://github.com/lbryio/lbry/blob/0b771c16ba058d3919b2bac482f4d725473a72fa/lbrynet/dht/node.py#L369

Is removing the from_peer handling intentional?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see discussion at end here: #968

@kaykurokawa
Copy link
Copy Markdown
Contributor Author

After discussion with jack , it looks like his "from_peer" field never gets used except in the if statement we just removed. I added a commit 90060e9 that completely removes the addition of this "from_peer" field.

Also rebased to master.

blob_hash (str): blob hash to look for
timeout (int): seconds to timeout after
filter_self (bool): if True, and if a peer for a blob is itself, filter it
from the result
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(assume that I have not dug yet in the downloader code) I am wondering if knowing that self already has the blob could be a useful information to avoid downloading it again. Or is this case handled differently by the downloader (i.e. the downloader checks the blob directory directly before issuing a request)?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a BlobManager class which knows all the blobs it has. In theory , when the daemon is downloading it should not try to download blobs it has announced. But I think in practice, this can happen if for example you announce a blob, and than you delete the blob in blob manager and try to download the same blob again.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, it makes sense. Thanks for clarifying!

@kaykurokawa
Copy link
Copy Markdown
Contributor Author

Rebased to master,
this is LGTM

ordex and others added 6 commits November 7, 2017 09:56
If a node is returning a peer list for a given blob hash
(being this been requested via CLI or via DHT) and it is
part of the resulting peer list, it will filter itself out
before returning the list.

This makes the results across the DHT inconsistent as
different nodes won't include themselves when
responding a findValue/findNode query.

Remove such filtering so that the local node ID is always
included when needed.

Signed-off-by: Antonio Quartulli <antonio@mandelbit.com>
…s blobs, instead of specifying it in announceHaveBlob
… from peer list. Use this argument to remove itself from peer list when downloading blobs

do not filter self on peer list
@kaykurokawa kaykurokawa merged commit 7898f6f into master Nov 7, 2017
@kaykurokawa kaykurokawa deleted the ordex-dht-list-fix branch November 7, 2017 14:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants