Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
timothe
duniter
Commits
dd6a4f0d
Commit
dd6a4f0d
authored
May 12, 2020
by
Éloïs
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'feature/sync-duration' into dev
parents
1affed5f
65fe5616
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
7 deletions
+15
-7
app/modules/crawler/lib/sync.ts
app/modules/crawler/lib/sync.ts
+4
-2
app/modules/crawler/lib/sync/Watcher.ts
app/modules/crawler/lib/sync/Watcher.ts
+11
-5
No files found.
app/modules/crawler/lib/sync.ts
View file @
dd6a4f0d
...
...
@@ -140,6 +140,7 @@ export class Synchroniser extends stream.Duplex {
this
.
logger
.
info
(
"
Sync started.
"
);
const
fullSync
=
!
to
;
const
syncStartTime
=
Date
.
now
();
//============
// Blockchain headers
...
...
@@ -240,9 +241,10 @@ export class Synchroniser extends stream.Duplex {
await
this
.
syncStrategy
.
syncPeers
(
fullSync
,
to
);
}
this
.
watcher
.
end
();
const
syncDuration
=
Date
.
now
()
-
syncStartTime
;
this
.
watcher
.
end
(
syncDuration
);
this
.
push
({
sync
:
true
});
this
.
logger
.
info
(
"
Sync finished
.
"
);
this
.
logger
.
info
(
"
Sync finished
(duration %s ms).
"
,
syncDuration
);
}
catch
(
err
)
{
this
.
push
({
sync
:
false
,
msg
:
err
});
err
&&
...
...
app/modules/crawler/lib/sync/Watcher.ts
View file @
dd6a4f0d
...
...
@@ -11,7 +11,7 @@ export interface Watcher {
appliedPercent
(
pct
?:
number
):
number
;
sbxPercent
(
pct
?:
number
):
number
;
peersPercent
(
pct
?:
number
):
number
;
end
():
void
;
end
(
duration
?:
number
):
void
;
reserveNodes
(
nodesAvailable
:
P2pCandidate
[]):
void
;
...
...
@@ -114,8 +114,8 @@ export class EventWatcher extends events.EventEmitter implements Watcher {
return
method
(
pct
);
}
end
():
void
{
this
.
innerWatcher
.
end
();
end
(
syncDuration
?:
number
):
void
{
this
.
innerWatcher
.
end
(
syncDuration
);
}
onEvent
(
e
:
EventName
,
cb
:
(
pct
:
number
)
=>
void
)
{
...
...
@@ -261,8 +261,14 @@ export class MultimeterWatcher implements Watcher {
return
0
;
}
end
()
{
this
.
multi
.
write
(
"
\n
All done.
\n
"
);
end
(
duration
?:
number
)
{
if
(
duration
)
{
const
durationSecs
=
Math
.
floor
(
duration
/
1000
);
const
durationMillisRemain
=
duration
%
1000
;
this
.
multi
.
write
(
"
\n
All done in
"
+
durationSecs
+
"
.
"
+
durationMillisRemain
+
"
seconds.
\n
"
);
}
else
{
this
.
multi
.
write
(
"
\n
All done.
\n
"
);
}
this
.
multi
.
destroy
();
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment