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
f44b2af7
Commit
f44b2af7
authored
8 years ago
by
Cédric Moreau
Browse files
Options
Downloads
Patches
Plain Diff
Fixing #450 Add a synchronization bar on the UI while pulling blocks from the network
parent
666cb5cb
No related branches found
No related tags found
No related merge requests found
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
app/controllers/webmin.controller.js
+6
-0
6 additions, 0 deletions
app/controllers/webmin.controller.js
app/lib/streams/webmin.js
+6
-0
6 additions, 0 deletions
app/lib/streams/webmin.js
app/service/PeeringService.js
+28
-0
28 additions, 0 deletions
app/service/PeeringService.js
web-ui
+1
-1
1 addition, 1 deletion
web-ui
with
41 additions
and
1 deletion
app/controllers/webmin.controller.js
+
6
−
0
View file @
f44b2af7
...
...
@@ -30,6 +30,12 @@ function WebAdmin (dbConf, overConf) {
let
bmapi
;
const
that
=
this
;
server
.
pipe
(
es
.
mapSync
(
function
(
data
)
{
if
(
data
.
pulling
!==
undefined
)
{
that
.
push
(
data
);
}
}));
AbstractController
.
call
(
this
,
server
);
stream
.
Duplex
.
call
(
this
,
{
objectMode
:
true
});
...
...
This diff is collapsed.
Click to expand it.
app/lib/streams/webmin.js
+
6
−
0
View file @
f44b2af7
...
...
@@ -118,6 +118,12 @@ module.exports = function(dbConf, overConf, interfaces, httpLogs) {
value
:
data
.
stopped
}));
}
if
(
data
.
pulling
!==
undefined
)
{
wssEvents
.
broadcast
(
JSON
.
stringify
({
type
:
'
pulling
'
,
value
:
data
.
pulling
}));
}
}));
});
...
...
This diff is collapsed.
Click to expand it.
app/service/PeeringService.js
+
28
−
0
View file @
f44b2af7
...
...
@@ -489,10 +489,20 @@ function PeeringService(server) {
}
});
function
pullingEvent
(
type
,
number
)
{
server
.
push
({
pulling
:
{
type
:
type
,
data
:
number
}
});
}
function
syncBlock
(
callback
,
pubkey
)
{
currentSyncP
=
co
(
function
*
()
{
let
current
=
yield
dal
.
getCurrentBlockOrNull
();
if
(
current
)
{
pullingEvent
(
'
start
'
,
current
.
number
);
logger
.
info
(
"
Pulling blocks from the network...
"
);
let
peers
=
yield
dal
.
findAllPeersNEWUPBut
([
selfPubkey
]);
peers
=
_
.
shuffle
(
peers
);
...
...
@@ -501,11 +511,13 @@ function PeeringService(server) {
}
for
(
let
i
=
0
,
len
=
peers
.
length
;
i
<
len
;
i
++
)
{
let
p
=
new
Peer
(
peers
[
i
]);
pullingEvent
(
'
peer
'
,
_
.
extend
({
number
:
i
,
length
:
peers
.
length
},
p
));
logger
.
trace
(
"
Try with %s %s
"
,
p
.
getURL
(),
p
.
pubkey
.
substr
(
0
,
6
));
try
{
let
node
=
yield
p
.
connect
();
node
.
pubkey
=
p
.
pubkey
;
yield
checkPeerValidity
(
p
,
node
);
let
lastDownloaded
;
let
dao
=
pulling
.
abstractDao
({
// Get the local blockchain current block
...
...
@@ -537,6 +549,11 @@ function PeeringService(server) {
// Simulate the adding of a single new block on local blockchain
applyMainBranch
:
(
block
)
=>
co
(
function
*
()
{
let
addedBlock
=
yield
server
.
BlockchainService
.
submitBlock
(
block
,
true
,
constants
.
FORK_ALLOWED
);
if
(
!
lastDownloaded
)
{
lastDownloaded
=
yield
dao
.
remoteCurrent
(
node
);
}
pullingEvent
(
'
applying
'
,
{
number
:
block
.
number
,
last
:
lastDownloaded
.
number
});
current
=
addedBlock
;
server
.
streamPush
(
addedBlock
);
}),
...
...
@@ -550,6 +567,15 @@ function PeeringService(server) {
}),
// Simulates the downloading of blocks from a peer
downloadBlocks
:
(
thePeer
,
fromNumber
,
count
)
=>
co
(
function
*
()
{
if
(
!
count
)
{
count
=
CONST_BLOCKS_CHUNK
;
}
pullingEvent
(
'
downloading
'
,
count
);
const
blocks
=
yield
Q
.
nfcall
(
thePeer
.
blockchain
.
blocks
,
count
,
fromNumber
);
lastDownloaded
=
blocks
[
blocks
.
length
-
1
];
return
blocks
;
})
downloadBlocks
:
(
thePeer
,
fromNumber
,
count
)
=>
co
(
function
*
()
{
if
(
!
count
)
{
count
=
CONST_BLOCKS_CHUNK
;
...
...
@@ -577,11 +603,13 @@ function PeeringService(server) {
}
}
}
pullingEvent
(
'
end
'
,
current
.
number
);
}
logger
.
info
(
'
Will pull blocks from the network in %s min %s sec
'
,
Math
.
floor
(
SYNC_BLOCK_INTERVAL
/
60
),
Math
.
floor
(
SYNC_BLOCK_INTERVAL
%
60
));
callback
&&
callback
();
})
.
catch
((
err
)
=>
{
pullingEvent
(
'
error
'
);
logger
.
warn
(
err
.
code
||
err
.
stack
||
err
.
message
||
err
);
callback
&&
callback
();
});
...
...
This diff is collapsed.
Click to expand it.
web-ui
@
113f9176
Compare
084b5dc3
...
113f9176
Subproject commit
084b5dc344e57a673c1f1dd9bd8e5384365b9386
Subproject commit
113f9176e8b2281ab75ba02f854521b099a5e8c8
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