Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
duniter
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Monitor
Service Desk
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
nodes
typescript
duniter
Commits
fc7428f9
Commit
fc7428f9
authored
7 years ago
by
Éloïs
Browse files
Options
Downloads
Plain Diff
Merge branch 'fix/1.6/ws2p/outcoming_connection' into '1.6'
[enh]
#1254
Enhance the connection to outcoming WS2P peers See merge request
!1237
parents
d52a236f
b81c745b
No related branches found
No related tags found
1 merge request
!1237
[enh] #1254 Enhance the connection to outcoming WS2P peers
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
app/modules/ws2p/lib/WS2PCluster.ts
+39
-22
39 additions, 22 deletions
app/modules/ws2p/lib/WS2PCluster.ts
app/modules/ws2p/lib/constants.ts
+2
-0
2 additions, 0 deletions
app/modules/ws2p/lib/constants.ts
with
41 additions
and
22 deletions
app/modules/ws2p/lib/WS2PCluster.ts
+
39
−
22
View file @
fc7428f9
...
...
@@ -427,8 +427,24 @@ export class WS2PCluster {
let
i
=
0
let
countPublicNodesWithSameKey
:
number
=
1
// Necessary if maxPrivate = 0
let
endpointsNodesWithSameKey
:
WS2PEndpoint
[]
=
[]
while
(
i
<
peers
.
length
&&
(
this
.
clientsCount
()
<
this
.
maxLevel1Size
||
this
.
numberOfConnectedPublicNodesWithSameKey
()
<
countPublicNodesWithSameKey
)
)
{
const
p
=
peers
[
i
]
// Group the peers by bunches
const
bunchsOfPeers
=
peers
.
reduce
((
bundles
:
PeerDTO
[][],
p
:
PeerDTO
)
=>
{
let
bundleIndex
=
(
bundles
.
length
||
1
)
-
1
// Maximum size of a bundle of peers
if
(
bundles
[
bundleIndex
]
&&
bundles
[
bundleIndex
].
length
>=
WS2PConstants
.
INITIAL_CONNECTION_PEERS_BUNDLE_SIZE
)
{
bundleIndex
++
}
// We create the bundle of it doesn't exist yet
if
(
!
bundles
[
bundleIndex
])
{
bundles
[
bundleIndex
]
=
[]
}
// We feed it with this peer
bundles
[
bundleIndex
].
push
(
p
)
return
bundles
},
[])
while
(
i
<
bunchsOfPeers
.
length
&&
(
this
.
clientsCount
()
<
this
.
maxLevel1Size
||
this
.
numberOfConnectedPublicNodesWithSameKey
()
<
countPublicNodesWithSameKey
)
)
{
this
.
server
.
logger
.
info
(
"
WS2P: init: bundle of peers %s/%s
"
,
i
+
1
,
bunchsOfPeers
.
length
)
await
Promise
.
all
(
bunchsOfPeers
[
i
].
map
(
async
p
=>
{
if
(
p
.
pubkey
===
this
.
server
.
conf
.
pair
.
pub
)
{
endpointsNodesWithSameKey
=
p
.
getAllWS2PEndpoints
(
canReachTorEndpoint
,
canReachClearEndpoint
,
myUUID
)
countPublicNodesWithSameKey
=
endpointsNodesWithSameKey
.
length
...
...
@@ -453,6 +469,7 @@ export class WS2PCluster {
}
}
}
}))
i
++
// Trim the eventual extra connections
setTimeout
(()
=>
this
.
removeLowPriorityConnections
(
prefered
),
WS2PConstants
.
CONNEXION_TIMEOUT
)
...
...
This diff is collapsed.
Click to expand it.
app/modules/ws2p/lib/constants.ts
+
2
−
0
View file @
fc7428f9
...
...
@@ -78,5 +78,7 @@ export const WS2PConstants = {
HOST_ONION_REGEX
:
CommonConstants
.
HOST_ONION_REGEX
,
FULL_ADDRESS_ONION_REGEX
:
CommonConstants
.
WS_FULL_ADDRESS_ONION_REGEX
,
INITIAL_CONNECTION_PEERS_BUNDLE_SIZE
:
5
,
HEADS_SPREAD_TIMEOUT
:
100
// Wait 100ms before sending a bunch of signed heads
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment