Skip to content

Conversation

cytadela8
Copy link
Contributor

@cytadela8 cytadela8 commented Nov 11, 2017

This PR solves following problems:

  • When we know less then peers_target_count peers we add random peers from peers known by peers we know. (We request peers list from peers we know and add random peers from that list)
  • Max known peers count is now limited. When we try to add another one, but the max count is reached, we at random: remove one of known or ignore the new one.
  • When we know at least peers_target_count peers we remove one randomly every "sync loop".

Stuff missing for ready peers sync:

This replaces #120
This closes #115

@cytadela8
Copy link
Contributor Author

Please check and advice about code style. This is my first contribution so I probably violated some established rules.

else
case check_peer(uri, own_nonce) do
{:ok, info} ->
if map_size(peers) < @peers_max_count
Copy link
Collaborator

Choose a reason for hiding this comment

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

can we refactor this if condition into a function, to give it a name

@thepiwo
Copy link
Collaborator

thepiwo commented Nov 11, 2017

code style is good so far, we have no specific rules yet

end
end

defp should_a_peer_be_added peers_count do
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@thepiwo Is this what you thought of?

Copy link
Collaborator

Choose a reason for hiding this comment

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

yes great!

@meivantodorov meivantodorov merged commit 7075d93 into master Nov 13, 2017
@thepiwo thepiwo deleted the GH-115 branch October 5, 2018 11:48
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.

getting random peer from peers we connect to

4 participants