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
4f79d74c
Commit
4f79d74c
authored
Jul 12, 2016
by
inso
Browse files
Options
Downloads
Patches
Plain Diff
Syncing works too
parent
fd981c9e
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/lib/pulling.js
+8
-6
8 additions, 6 deletions
app/lib/pulling.js
app/lib/sync.js
+10
-3
10 additions, 3 deletions
app/lib/sync.js
with
18 additions
and
9 deletions
app/lib/pulling.js
+
8
−
6
View file @
4f79d74c
...
@@ -15,12 +15,14 @@ module.exports = {
...
@@ -15,12 +15,14 @@ module.exports = {
* Sugar function. Apply a bunch of blocks instead of one.
* Sugar function. Apply a bunch of blocks instead of one.
* @param blocks
* @param blocks
*/
*/
if
(
!
dao
.
applyBranch
)
{
dao
.
applyBranch
=
(
blocks
)
=>
co
(
function
*
()
{
dao
.
applyBranch
=
(
blocks
)
=>
co
(
function
*
()
{
for
(
const
block
of
blocks
)
{
for
(
const
block
of
blocks
)
{
yield
dao
.
applyMainBranch
(
block
);
yield
dao
.
applyMainBranch
(
block
);
}
}
return
true
;
return
true
;
});
});
}
/**
/**
* Binary search algorithm to find the common root block between a local and a remote blockchain.
* Binary search algorithm to find the common root block between a local and a remote blockchain.
...
...
This diff is collapsed.
Click to expand it.
app/lib/sync.js
+
10
−
3
View file @
4f79d74c
...
@@ -140,17 +140,24 @@ function Synchroniser (server, host, port, conf, interactive) {
...
@@ -140,17 +140,24 @@ function Synchroniser (server, host, port, conf, interactive) {
return
blocks
;
return
blocks
;
}),
}),
applyMainBranch
:
(
blocks
)
=>
co
(
function
*
()
{
applyBranch
:
(
blocks
)
=>
co
(
function
*
()
{
if
(
cautious
)
{
if
(
cautious
)
{
for
(
const
block
of
blocks
)
{
for
(
const
block
of
blocks
)
{
const
addedBlock
=
yield
server
.
BlockchainService
.
submitBlock
(
block
,
true
,
constants
.
FORK_ALLOWED
);
yield
dao
.
applyMainBranch
(
block
);
server
.
streamPush
(
addedBlock
);
}
}
}
else
{
}
else
{
yield
server
.
BlockchainService
.
saveBlocksInMainBranch
(
blocks
);
yield
server
.
BlockchainService
.
saveBlocksInMainBranch
(
blocks
);
}
}
this
.
lastBlock
=
blocks
[
blocks
.
length
-
1
];
this
.
lastBlock
=
blocks
[
blocks
.
length
-
1
];
watcher
.
appliedPercent
(
Math
.
floor
(
blocks
[
blocks
.
length
-
1
].
number
/
to
*
100
));
watcher
.
appliedPercent
(
Math
.
floor
(
blocks
[
blocks
.
length
-
1
].
number
/
to
*
100
));
return
true
;
}),
applyMainBranch
:
(
block
)
=>
co
(
function
*
()
{
const
addedBlock
=
yield
server
.
BlockchainService
.
submitBlock
(
block
,
true
,
constants
.
FORK_ALLOWED
);
server
.
streamPush
(
addedBlock
);
watcher
.
appliedPercent
(
Math
.
floor
(
block
.
number
/
to
*
100
));
}),
}),
// Eventually remove forks later on
// Eventually remove forks later on
...
...
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
sign in
to comment