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 typos and ensure odd-numbered channels have odd numbers #587

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
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
Prev Previous commit
Ensure odd-numbered channels have odd numbers
  • Loading branch information
jes committed Sep 5, 2018
commit 25824b65d69beb57d1921aa50742e8754841a0f8
3 changes: 1 addition & 2 deletions src/protocol/Connection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -470,8 +470,7 @@ int ConnectionPrivate::availableOutboundChannelId()
// Find an unused id, trying a maximum of 100 times, using a random step to avoid collision
for (int i = 0; i < 100 && channels.contains(nextOutboundChannelId); i++) {
nextOutboundChannelId += 1 + (qrand() % 200);
if (evenNumbered)
nextOutboundChannelId += nextOutboundChannelId % 2;
nextOutboundChannelId += (nextOutboundChannelId % 2) + (evenNumbered ? 0 : 1);
if (nextOutboundChannelId > maxId)
nextOutboundChannelId = minId;
}
Expand Down