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

P2p outbound #515

Merged
merged 20 commits into from
Jun 13, 2018
Merged

P2p outbound #515

merged 20 commits into from
Jun 13, 2018

Conversation

AionJayT
Copy link
Collaborator

@AionJayT AionJayT commented Jun 1, 2018

Notice

It is not allowed to submit your PR to the master branch directly, please submit your PR to the master-pre-merge branch.

Description

Please include a brief summary of the change that this pull request proposes. Include any relevant motivation and context. List any dependencies required for this change.

  • module p2pImpl refactor, improved the outbound thread reacting, decreased Cpu wasting time by 80% also avoid the outbound msg time-out.

Also, the PR #518 including this PR, therefore, some of the comments will be revised in the #518.

Type of change

Insert x into the following checkboxes to confirm (eg. [x]):

  • Bug fix.
  • New feature.
  • Enhancement/Refactoring
  • Breaking change (a fix or feature that causes existing functionality to not work as expected).
  • Requires documentation update.

Testing

Please describe the tests you used to validate this pull request. Provide any relevant details for test configurations as well as any instructions to reproduce these results.

  • the unit test will be done by @aion-sridevi. currently running few nodes connecting with Mainnet.

Verification

Insert x into the following checkboxes to confirm (eg. [x]):

  • I have self-reviewed my own code and conformed to the style guidelines of this project.
  • New and existing tests pass locally with my changes.
  • I have added tests for my fix or feature.
  • I have made appropriate changes to the corresponding documentation.
  • My code generates no new warnings.
  • Any dependent changes have been made.

@AionJayT AionJayT added the enhancement New feature or request label Jun 1, 2018
@AionJayT AionJayT added this to the v0.2.9 - Moldoveanu Peak milestone Jun 1, 2018
private final int maxActiveNodes;

private final int maxTempNodes;

private static final Random random = new SecureRandom(ByteBuffer.allocate(Long.BYTES).putLong(System.currentTimeMillis()).array());
Copy link
Contributor

Choose a reason for hiding this comment

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

What is the rationale behind seeding the secure random? My opinion is that our seed is less secure than if random came from a random source.

Copy link
Collaborator Author

@AionJayT AionJayT Jun 5, 2018

Choose a reason for hiding this comment

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

the original code generate a Random object in each getRandom call, I think it's resource waste, But I agree to use current system time will cause less secure. will change to use default constructor of the SecureRandom class.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

changed in 154167d

else {
if (previous != null) {
_p2pMgr.closeSocket(node.getChannel(),
"outbound -> active, node " + previous.getIdShort() + " exits");
Copy link
Contributor

Choose a reason for hiding this comment

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

Minor typo: it should read "exists" instead of "exits"

activeNodes.clear();
}

} catch (Exception e) {

e.printStackTrace();
Copy link
Contributor

Choose a reason for hiding this comment

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

May be log the exception?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

fixed in the PR #518 93da2b6


private static final int TOTAL_LANE = Math
.min(Runtime.getRuntime().availableProcessors() << 1, 32);
private static final int threadQlimit = 20000;
Copy link
Contributor

Choose a reason for hiding this comment

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

Minor: threadQlimit could be all caps since its a constant

@@ -72,8 +92,8 @@ public void run() {
}

// if not belong to current lane, put it back.
int targetLane = hash2Lane(mo.getNodeId());
if (targetLane != lane) {
long t1 = System.nanoTime();
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't see t1 being used, can be removed

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

yep, it has been removed in the other PR #518

@AionJayT AionJayT merged commit 382531f into master-pre-merge Jun 13, 2018
@AionJayT AionJayT mentioned this pull request Jun 14, 2018
10 tasks
@AionJayT AionJayT deleted the p2p-outbound branch June 14, 2018 20:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants