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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
nodes
typescript
duniter
Commits
c5669eb3
Commit
c5669eb3
authored
9 years ago
by
Cédric Moreau
Browse files
Options
Downloads
Patches
Plain Diff
Fix: follow a fork that with exact or more than 30 minutes of time advance
parent
d7114652
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
app/service/BlockchainService.js
+1
-1
1 addition, 1 deletion
app/service/BlockchainService.js
test/integration/branches_switch.js
+4
-0
4 additions, 0 deletions
test/integration/branches_switch.js
with
5 additions
and
1 deletion
app/service/BlockchainService.js
+
1
−
1
View file @
c5669eb3
...
@@ -178,7 +178,7 @@ function BlockchainService () {
...
@@ -178,7 +178,7 @@ function BlockchainService () {
let
blocksAdvance
=
constants
.
BRANCHES
.
SWITCH_ON_BRANCH_AHEAD_BY_X_MINUTES
/
(
conf
.
avgGenTime
/
60
);
let
blocksAdvance
=
constants
.
BRANCHES
.
SWITCH_ON_BRANCH_AHEAD_BY_X_MINUTES
/
(
conf
.
avgGenTime
/
60
);
let
timeAdvance
=
constants
.
BRANCHES
.
SWITCH_ON_BRANCH_AHEAD_BY_X_MINUTES
*
60
;
let
timeAdvance
=
constants
.
BRANCHES
.
SWITCH_ON_BRANCH_AHEAD_BY_X_MINUTES
*
60
;
// We switch only to blockchain with X_MIN advance considering both theoretical time by block + written time
// We switch only to blockchain with X_MIN advance considering both theoretical time by block + written time
potentials
=
_
.
filter
(
potentials
,
(
p
)
=>
p
.
number
-
current
.
number
>
blocksAdvance
&&
p
.
medianTime
-
current
.
medianTime
>
timeAdvance
);
potentials
=
_
.
filter
(
potentials
,
(
p
)
=>
p
.
number
-
current
.
number
>
=
blocksAdvance
&&
p
.
medianTime
-
current
.
medianTime
>
=
timeAdvance
);
logger
.
trace
(
'
SWITCH: %s branches...
'
,
branches
.
length
);
logger
.
trace
(
'
SWITCH: %s branches...
'
,
branches
.
length
);
logger
.
trace
(
'
SWITCH: %s potential side chains...
'
,
potentials
.
length
);
logger
.
trace
(
'
SWITCH: %s potential side chains...
'
,
potentials
.
length
);
for
(
let
i
=
0
,
len
=
potentials
.
length
;
i
<
len
;
i
++
)
{
for
(
let
i
=
0
,
len
=
potentials
.
length
;
i
<
len
;
i
++
)
{
...
...
This diff is collapsed.
Click to expand it.
test/integration/branches_switch.js
+
4
−
0
View file @
c5669eb3
...
@@ -9,6 +9,7 @@ var rp = require('request-promise');
...
@@ -9,6 +9,7 @@ var rp = require('request-promise');
var
httpTest
=
require
(
'
./tools/http
'
);
var
httpTest
=
require
(
'
./tools/http
'
);
var
commit
=
require
(
'
./tools/commit
'
);
var
commit
=
require
(
'
./tools/commit
'
);
var
sync
=
require
(
'
./tools/sync
'
);
var
sync
=
require
(
'
./tools/sync
'
);
var
constants
=
require
(
'
./../../app/lib/constants
'
);
var
expectJSON
=
httpTest
.
expectJSON
;
var
expectJSON
=
httpTest
.
expectJSON
;
var
expectHttpCode
=
httpTest
.
expectHttpCode
;
var
expectHttpCode
=
httpTest
.
expectHttpCode
;
...
@@ -20,6 +21,7 @@ var commonConf = {
...
@@ -20,6 +21,7 @@ var commonConf = {
currency
:
'
bb
'
,
currency
:
'
bb
'
,
httpLogs
:
true
,
httpLogs
:
true
,
forksize
:
3
,
forksize
:
3
,
avgGenTime
:
1
,
parcatipate
:
false
,
// TODO: to remove when startGeneration will be an explicit call
parcatipate
:
false
,
// TODO: to remove when startGeneration will be an explicit call
sigQty
:
1
sigQty
:
1
};
};
...
@@ -80,7 +82,9 @@ describe("Switch", function() {
...
@@ -80,7 +82,9 @@ describe("Switch", function() {
// So we now have:
// So we now have:
// S1 01234
// S1 01234
// S2 `3456789
// S2 `3456789
let
oldVal
=
constants
.
BRANCHES
.
SWITCH_ON_BRANCH_AHEAD_BY_X_MINUTES
=
0
;
yield
sync
(
3
,
8
,
s2
,
s1
);
yield
sync
(
3
,
8
,
s2
,
s1
);
constants
.
BRANCHES
.
SWITCH_ON_BRANCH_AHEAD_BY_X_MINUTES
=
oldVal
;
// S1 should have switched to the other branch
// S1 should have switched to the other branch
});
});
});
});
...
...
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