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
0873bec2
Unverified
Commit
0873bec2
authored
7 years ago
by
Éloïs
Browse files
Options
Downloads
Plain Diff
add downward compatibility
parents
fe063ef0
796c08eb
Branches
Branches containing commit
Tags
Tags containing commit
3 merge requests
!1222
Add startup scripts
,
!1220
Stable/ws2p v1.1 trymerge
,
!1208
Stable/ws2p v1.1
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
app/lib/common-libs/constants.ts
+4
-4
4 additions, 4 deletions
app/lib/common-libs/constants.ts
app/modules/ws2p/lib/WS2PCluster.ts
+12
-6
12 additions, 6 deletions
app/modules/ws2p/lib/WS2PCluster.ts
app/modules/ws2p/lib/constants.ts
+1
-0
1 addition, 0 deletions
app/modules/ws2p/lib/constants.ts
with
17 additions
and
10 deletions
app/lib/common-libs/constants.ts
+
4
−
4
View file @
0873bec2
...
...
@@ -32,10 +32,10 @@ const CONDITIONS = "(&&|\\|\\|| |[()]|(SIG\\(" + PUBKEY + "\\)|(XHX\\([A-F0-9]
const
BMA_REGEXP
=
/^BASIC_MERKLED_API
(
([
a-z_
][
a-z0-9-_.
]
*
))?(
([
0-9.
]
+
))?(
([
0-9a-f:
]
+
))?(
([
0-9
]
+
))
$/
const
BMATOR_REGEXP
=
/^BMATOR
(
([
a-z0-9
]{16})\.
onion
)(
([
0-9.
]
+
))?(
([
0-9a-f:
]
+
))?(
([
0-9
]
+
))
$/
const
WS2P_REGEXP
=
/^WS2P
([
a-f0-9
]{8})
([
a-z_
][
a-z0-9-_.
]
*|
[
0-9.
]
+|
[
0-9a-f:
]
+
)
([
0-9
]
+
)(?:
(
.+
))?
$/
const
WS2P_V2_REGEXP
=
/^WS2P
([
0-9
]
+
)
([
a-f0-9
]{8})
([
a-z_
][
a-z0-9-_.
]
*|
[
0-9.
]
+|
[
0-9a-f:
]
+
)
([
0-9
]
+
)(?:
(
.+
))?
$/
const
WS2PTOR_REGEXP
=
/^WS2PTOR
([
a-f0-9
]{8})
([
a-z0-9-_.
]
*|
[
0-9.
]
+|
[
0-9a-f:
]
+.onion
)
([
0-9
]
+
)(?:
(
.+
))?
$/
const
WS2PTOR_V2_REGEXP
=
/^WS2PTOR
([
0-9
]
+
)
([
a-f0-9
]{8})
([
a-z0-9-_.
]
*|
[
0-9.
]
+|
[
0-9a-f:
]
+.onion
)
([
0-9
]
+
)(?:
(
.+
))?
$/
const
WS2P_REGEXP
=
/^WS2P
(?:[
1-9
][
0-9
]
*
)?
([
a-f0-9
]{8})
([
a-z_
][
a-z0-9-_.
]
*|
[
0-9.
]
+|
[
0-9a-f:
]
+
)
([
0-9
]
+
)(?:
(
.+
))?
$/
const
WS2P_V2_REGEXP
=
/^WS2P
([
1-9
][
0-9
]
*
)
([
a-f0-9
]{8})
([
a-z_
][
a-z0-9-_.
]
*|
[
0-9.
]
+|
[
0-9a-f:
]
+
)
([
0-9
]
+
)(?:
(
.+
))?
$/
const
WS2PTOR_REGEXP
=
/^WS2PTOR
(?:[
1-9
][
0-9
]
*
)?
([
a-f0-9
]{8})
([
a-z0-9-_.
]
*|
[
0-9.
]
+|
[
0-9a-f:
]
+.onion
)
([
0-9
]
+
)(?:
(
.+
))?
$/
const
WS2PTOR_V2_REGEXP
=
/^WS2PTOR
([
1-9
][
0-9
]
*
)
([
a-f0-9
]{8})
([
a-z0-9-_.
]
*|
[
0-9.
]
+|
[
0-9a-f:
]
+.onion
)
([
0-9
]
+
)(?:
(
.+
))?
$/
const
WS_FULL_ADDR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
25
[
0-5
])
|
(
1d
{2})
|
(
2
[
0-4
]
d
)
|
(
d
{1,2}))
b
)
.
){3}(
b
((
25
[
0-5
])
|
(
1d
{2})
|
(
2
[
0-4
]
d
)
|
(
d
{1,2}))
b
))
|
([
0-9A-Fa-f
]{1,4}
::
([
0-9A-Fa-f
]{1,4}
:
){0,5}[
0-9A-Fa-f
]{1,4})
|
(
::
([
0-9A-Fa-f
]{1,4}
:
){0,6}[
0-9A-Fa-f
]{1,4})
|
(([
0-9A-Fa-f
]{1,4}
:
){1,7}
:
))
$/
;
...
...
This diff is collapsed.
Click to expand it.
app/modules/ws2p/lib/WS2PCluster.ts
+
12
−
6
View file @
0873bec2
...
...
@@ -26,6 +26,11 @@ const _ = require('underscore')
export
interface
WS2PHead
{
message
:
string
sig
:
string
step
?:
number
}
export
interface
WS2pHeadCache
extends
WS2PHead
{
blockstamp
:
string
}
export
class
WS2PCluster
{
...
...
@@ -70,11 +75,11 @@ export class WS2PCluster {
// A cache to know wether a pubkey is a member or not
private
memberkeysCache
:{
[
k
:
string
]:
number
}
=
{}
// A cache of the current HEAD for a given
pubkey
private
headsCache
:{
[
ws2pFullId
:
string
]:
{
blockstamp
:
string
,
message
:
string
,
sig
:
string
}
}
=
{}
// A cache of the current HEAD for a given
ws2pFullId
private
headsCache
:{
[
ws2pFullId
:
string
]:
WS2pHeadCache
}
=
{}
// A buffer of "to be sent" heads
private
newHeads
:
{
message
:
string
,
sig
:
string
}
[]
=
[]
private
newHeads
:
WS2PHead
[]
=
[]
// The triggerer of a buffer of heads' sending
private
headsTimeout
:
NodeJS
.
Timer
|
null
=
null
...
...
@@ -112,10 +117,11 @@ export class WS2PCluster {
return
heads
}
async
headsReceived
(
heads
:
[{
message
:
string
,
sig
:
string
}
])
{
const
added
:
{
message
:
string
,
sig
:
string
}
[]
=
[]
await
Promise
.
all
(
heads
.
map
(
async
(
h
:
{
message
:
string
,
sig
:
string
}
)
=>
{
async
headsReceived
(
heads
:
WS2PHead
[
])
{
const
added
:
WS2PHead
[]
=
[]
await
Promise
.
all
(
heads
.
map
(
async
(
h
:
WS2PHead
)
=>
{
try
{
const
step
=
(
h
.
step
!==
undefined
)
?
h
.
step
:
undefined
const
message
=
h
.
message
const
sig
=
h
.
sig
if
(
!
message
)
{
...
...
This diff is collapsed.
Click to expand it.
app/modules/ws2p/lib/constants.ts
+
1
−
0
View file @
0873bec2
...
...
@@ -46,6 +46,7 @@ export const WS2PConstants = {
+
'
(
'
+
CommonConstants
.
FORMATS
.
SOFTWARE
+
'
):
'
+
'
(
'
+
CommonConstants
.
FORMATS
.
SOFT_VERSION
+
'
):
'
+
'
(
'
+
CommonConstants
.
FORMATS
.
POW_PREFIX
+
'
)
'
+
'
(?::
'
+
CommonConstants
.
FORMATS
.
TIMESTAMP
+
'
)?
'
+
'
$
'
),
HOST_ONION_REGEX
:
CommonConstants
.
HOST_ONION_REGEX
,
...
...
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