Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix p2p filter unconnected peers #1160

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
93060a2
Merge pull request #1 from neo-project/master
Tommo-L Jun 4, 2019
f4371d3
Merge pull request #3 from neo-project/master
Tommo-L Jun 20, 2019
5784ac5
Merge pull request #5 from neo-project/master
Tommo-L Jun 28, 2019
d8ab5e2
Merge pull request #6 from neo-project/master
Tommo-L Jul 8, 2019
9a1f07a
Merge pull request #7 from neo-project/master
Tommo-L Jul 16, 2019
ee20bc9
add internal to DB and WriteBatch
eryeer Jul 16, 2019
4d873e2
Merge branch 'master' into master
eryeer Jul 17, 2019
81dd495
Merge branch 'master' into master
lock9 Jul 18, 2019
5518fbd
Merge branch 'master' into master
eryeer Jul 22, 2019
60a1845
Merge pull request #8 from neo-project/master
Tommo-L Sep 23, 2019
97c2f34
Merge pull request #9 from neo-project/master
Tommo-L Sep 26, 2019
639c739
Merge remote-tracking branch 'upstream/master'
Sep 27, 2019
6376be1
Merge remote-tracking branch 'upstream/master'
Oct 9, 2019
b76b04d
reset db.cs writebatch.cs
Oct 12, 2019
a34254b
Merge remote-tracking branch 'upstream/master'
Oct 18, 2019
9b380a7
filter unconnected peers
Oct 18, 2019
0ae6b17
Merge branch 'master' into fix_p2p_filter_unconnected_peers
vncoelho Oct 18, 2019
17d9e9d
add MaxCountFromSeedList variable
Oct 18, 2019
dc60fdd
Merge branch 'fix_p2p_filter_unconnected_peers' of https://github.com…
Oct 18, 2019
a610ab6
Merge branch 'master' into fix_p2p_filter_unconnected_peers
vncoelho Oct 23, 2019
312d9b9
Merge branch 'master' into fix_p2p_filter_unconnected_peers
erikzhang Oct 24, 2019
ff5bc82
Merge branch 'master' into fix_p2p_filter_unconnected_peers
Nov 4, 2019
f3510b2
Merge branch 'master' into fix_p2p_filter_unconnected_peers
Nov 6, 2019
3777018
Merge branch 'master' into fix_p2p_filter_unconnected_peers
erikzhang Nov 7, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion neo/Network/P2P/LocalNode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ internal class RelayDirectly { public IInventory Inventory; }
internal class SendDirectly { public IInventory Inventory; }

public const uint ProtocolVersion = 0;
private const int MaxCountFromSeedList = 5;

private static readonly object lockObj = new object();
private readonly NeoSystem system;
Expand Down Expand Up @@ -123,7 +124,7 @@ public IEnumerable<IPEndPoint> GetUnconnectedPeers()

protected override void NeedMorePeers(int count)
{
count = Math.Max(count, 5);
count = Math.Max(count, MaxCountFromSeedList);
if (ConnectedPeers.Count > 0)
{
BroadcastMessage(MessageCommand.GetAddr);
Expand Down
2 changes: 1 addition & 1 deletion neo/Network/P2P/Peer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ protected void AddPeers(IEnumerable<IPEndPoint> peers)
{
if (UnconnectedPeers.Count < UnconnectedMax)
{
peers = peers.Where(p => p.Port != ListenerTcpPort || !localAddresses.Contains(p.Address));
peers = peers.Where(p => (p.Port != ListenerTcpPort || !localAddresses.Contains(p.Address)) && !ConnectedPeers.Values.Contains(p));
ImmutableInterlocked.Update(ref UnconnectedPeers, p => p.Union(peers));
}
}
Expand Down